Working around johnzon REST implementation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Working around johnzon REST implementation

jayleg

We upgraded from 1.7.4 to 7.1.0, and we’re in the process of testing.  We came across a problem (see error below) related to the new johnzon implementation.  To work around the problem, we’re attempting to revert back to the previous implementation by adding resources.xml and openejb-jar.xml.  With the changes, the application now starts fine, but we’re now getting 404s when making a POST request.  Any thoughts on what’s causing the 404?

 

resources.xml

<?xml version="1.0" encoding="UTF-8"?>

<resources>

    <Service id="oldprovider" class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">

    </Service>

</resources>

 

openejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>

<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">

    <pojo-deployment class-name="com.lenovo.RestClass">

        <properties>

            cxf.jaxrs.providers = oldprovider

        </properties>

    </pojo-deployment>

</openejb-jar>

 

Johnzon error

 at org.apache.johnzon.core.JsonGeneratorImpl.close(JsonGeneratorImpl.java:454)

        at org.apache.johnzon.mapper.Mapper.writeObject(Mapper.java:147)

        at org.apache.johnzon.mapper.Mapper.writeObject(Mapper.java:182)

        at org.apache.johnzon.jsonb.JohnzonJsonb.toJson(JohnzonJsonb.java:317)

        at org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider.writeTo(JsonbJaxrsProvider.java:171)

        at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1417)

        at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:245)

 


Jay Leggett
Software Engineer
Lenovo United States

(919) 237-8165
[hidden email]

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Working around johnzon REST implementation

Cesar Hernandez
With the information you provided, it seems that you configurations it's ok.

To have a point of comparison, you can take a look at the example we have:
https://github.com/apache/tomee/tree/master/examples/jaxrs-json-provider-jettison
and also to this article:
https://www.tomitribe.com/blog/upgrading-tomee-keeping-jettison-as-the-json-provider-in-jax-rs/

El mar., 2 jul. 2019 a las 11:44, Jay Leggett (<[hidden email]>)
escribió:

> We upgraded from 1.7.4 to 7.1.0, and we’re in the process of testing.  We
> came across a problem (see error below) related to the new johnzon
> implementation.  To work around the problem, we’re attempting to revert
> back to the previous implementation by adding resources.xml and
> openejb-jar.xml.  With the changes, the application now starts fine, but
> we’re now getting 404s when making a POST request.  Any thoughts on what’s
> causing the 404?
>
>
>
> resources.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <resources>
>
>     <Service id="oldprovider"
> class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>
>     </Service>
>
> </resources>
>
>
>
> openejb-jar.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
>
>     <pojo-deployment class-name="com.lenovo.RestClass">
>
>         <properties>
>
>             cxf.jaxrs.providers = oldprovider
>
>         </properties>
>
>     </pojo-deployment>
>
> </openejb-jar>
>
>
>
> *Johnzon error*
>
>  at
> org.apache.johnzon.core.JsonGeneratorImpl.close(JsonGeneratorImpl.java:454)
>
>         at org.apache.johnzon.mapper.Mapper.writeObject(Mapper.java:147)
>
>         at org.apache.johnzon.mapper.Mapper.writeObject(Mapper.java:182)
>
>         at
> org.apache.johnzon.jsonb.JohnzonJsonb.toJson(JohnzonJsonb.java:317)
>
>         at
> org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider.writeTo(JsonbJaxrsProvider.java:171)
>
>         at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1417)
>
>         at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:245)
>
>
> ------------------------------
>
> *Jay Leggett*
> Software Engineer
> Lenovo United States
>
> [image: Phone](919) 237-8165
> [image: Email][hidden email] <[hidden email]>
>
>
>
>
>
> [image: RedLogo]
>
>
>
>
>


--
Atentamente:
César Hernández.