You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by tam <ta...@tamatzner.de> on 2016/05/31 12:33:53 UTC

JsonGenerationException after migrating to 7.0.0

Dear colleagues,

until recently, I have been using 1.7.4 for developing a web app. I had the
following Gradle setup (most probably not optimal, but working):



I am writing REST services like this:



where Module is a POJO having javax.xml.bind... annotations.

When migrating to 7.0.0, I wanted to do things right, using



No matter whether I replaced the latter two by providedCompile as well or
not, I got an error, obviously while trying to serialize the response to my
POST (probably while trying to serialize the response content of type Long):



Is there anything special to note about that JAX-RS library? Using my old
Gradle config with the new TomEE release doesn't help either, so for the
moment I'm stuck with 1.7.4.

Thanks in advance for any hint.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JsonGenerationException after migrating to 7.0.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
current/original website is
http://svn.apache.org/repos/asf/tomee/site/trunk/content/, you can put it
anywhere and link it on other pages if you want. It is markdown based so
easy to edit normally. The "ng" version is for now there
https://github.com/rmannibucau/site-tomee-ng/tree/master/src/main/jbake/content
(it uses adoc and has a JBake class to run the server)


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-06-01 9:23 GMT+02:00 tam <ta...@tamatzner.de>:

> I'll be glad to submit some documentation. Could you please give me an URL
> where it should be placed? But before that, some points will need to be
> clarified about Johnzon. I'll open another thread for that.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678706.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JsonGenerationException after migrating to 7.0.0

Posted by tam <ta...@tamatzner.de>.
I'll be glad to submit some documentation. Could you please give me an URL
where it should be placed? But before that, some points will need to be
clarified about Johnzon. I'll open another thread for that.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678706.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JsonGenerationException after migrating to 7.0.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
done on http://tomee.apache.org/ng/developer/json/index.html


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-05-31 18:15 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:

> Fell free to enhance the doc (anyone can edit it then we accept/edit
> changes). We tend to rely on the library doc instead of copying tons of doc
> on tomee side (otherwise we would need to copy johnzon, cxf, activemq,
> jaxb...docs). Johnzon is being migrated to a top level project so doc is
> not yet perfect but will be enhanced in coming weeks (check it at
> http://johnzon.apache.org/ in few days). I'll try to also enhance tomee
> doc this week on that point
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2016-05-31 17:35 GMT+02:00 tam <ta...@tamatzner.de>:
>
>> Thanks, removing the wrapper did the trick. The documentation, however, is
>> still extremely poor. In the Golden Ages, there used to be migration
>> guides
>> for cases like this. Hope there won't be more surprises.
>>
>>
>>
>> --
>> View this message in context:
>> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678699.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.
>>
>
>

Re: JsonGenerationException after migrating to 7.0.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Fell free to enhance the doc (anyone can edit it then we accept/edit
changes). We tend to rely on the library doc instead of copying tons of doc
on tomee side (otherwise we would need to copy johnzon, cxf, activemq,
jaxb...docs). Johnzon is being migrated to a top level project so doc is
not yet perfect but will be enhanced in coming weeks (check it at
http://johnzon.apache.org/ in few days). I'll try to also enhance tomee doc
this week on that point


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-05-31 17:35 GMT+02:00 tam <ta...@tamatzner.de>:

> Thanks, removing the wrapper did the trick. The documentation, however, is
> still extremely poor. In the Golden Ages, there used to be migration guides
> for cases like this. Hope there won't be more surprises.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678699.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JsonGenerationException after migrating to 7.0.0

Posted by tam <ta...@tamatzner.de>.
Thanks, removing the wrapper did the trick. The documentation, however, is
still extremely poor. In the Golden Ages, there used to be migration guides
for cases like this. Hope there won't be more surprises.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678699.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JsonGenerationException after migrating to 7.0.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
https://java.net/projects/jsonb-spec/pages/Home is the home for jsonb. Note
that we don't use it yet in tomee cause it requires java 8 but johnzon
mapper is pretty close. In two works it is to map 1-1 with java (property
foo will be a foo attribute in json compared to jaxb style mapping which
needs at least one wrapper at root level).

This change is not in 7.0.0 cause it is there since several versions (
https://issues.apache.org/jira/browse/TOMEE-1700,
https://issues.apache.org/jira/browse/TOMEE-1353)


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-05-31 16:38 GMT+02:00 tam <ta...@tamatzner.de>:

> I couldn't find anything concerning this in the release notes
> http://tomee.apache.org/tomee-7.0.0-release-notes.html. Anyway, it sounds
> interesting. Is there any pointer what to change to make use of that new
> way
> of JSON mapping? I wasn't a fan of the XmlElement annotations... Googling
> for jsonb yields results for a Postgres feature. And documentation of that
> Johnzon is virtually non-existent.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678696.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JsonGenerationException after migrating to 7.0.0

Posted by tam <ta...@tamatzner.de>.
I couldn't find anything concerning this in the release notes
http://tomee.apache.org/tomee-7.0.0-release-notes.html. Anyway, it sounds
interesting. Is there any pointer what to change to make use of that new way
of JSON mapping? I wasn't a fan of the XmlElement annotations... Googling
for jsonb yields results for a Postgres feature. And documentation of that
Johnzon is virtually non-existent.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678696.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JsonGenerationException after migrating to 7.0.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Yep, this is traced in release notes. Basically from jettison we miragted
to johnzon to have a better json mapping and moreover a mapping closer to
jsonb spec which will come and to not rely on jaxb.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-05-31 16:12 GMT+02:00 tam <ta...@tamatzner.de>:

> I'll try to isolate the error. Roughly, I'm sending a JSON structure for an
> entire application object (my Module from the example above) from the
> client
> to the server where I have the PUT method from the example. Neither of the
> JSON attributes are mapped to the Module parameter, so an empty Java object
> is created and inserted in the database. But at that point, the called
> service doesn't provide any error log, so I have no idea whether the
> deserialization is called at all, can't interpret the JSON structure, or
> whatever. All I know is that it works with the old library setup on 1.7.4
> that I sent you in my original question. So there appear to be
> compatibility
> issues between different implementations of JAX-RS.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678693.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JsonGenerationException after migrating to 7.0.0

Posted by tam <ta...@tamatzner.de>.
I'll try to isolate the error. Roughly, I'm sending a JSON structure for an
entire application object (my Module from the example above) from the client
to the server where I have the PUT method from the example. Neither of the
JSON attributes are mapped to the Module parameter, so an empty Java object
is created and inserted in the database. But at that point, the called
service doesn't provide any error log, so I have no idea whether the
deserialization is called at all, can't interpret the JSON structure, or
whatever. All I know is that it works with the old library setup on 1.7.4
that I sent you in my original question. So there appear to be compatibility
issues between different implementations of JAX-RS.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678693.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JsonGenerationException after migrating to 7.0.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
can you give us more details on what is not mapped? Johnzon is used on
several tomee 1.7 instances with success.

Side note: a better compromise is to just add the provider you want in
tomee 7 or your app and configure it to handle json.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-05-31 15:51 GMT+02:00 tam <ta...@tamatzner.de>:

> Thanks for the explanation. As that Johnzon thing appears not to properly
> map
> JSON structures coming from the client either, I'm afraid I'll have to stay
> with 1.7.4. Never replace a running library...
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678691.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JsonGenerationException after migrating to 7.0.0

Posted by tam <ta...@tamatzner.de>.
Thanks for the explanation. As that Johnzon thing appears not to properly map
JSON structures coming from the client either, I'm afraid I'll have to stay
with 1.7.4. Never replace a running library...



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678691.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JsonGenerationException after migrating to 7.0.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

is module.getId() a String and not a json object? We would need the exact
payload you return to check what's happening.



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-05-31 14:33 GMT+02:00 tam <ta...@tamatzner.de>:

> Dear colleagues,
>
> until recently, I have been using 1.7.4 for developing a web app. I had the
> following Gradle setup (most probably not optimal, but working):
>
>
>
> I am writing REST services like this:
>
>
>
> where Module is a POJO having javax.xml.bind... annotations.
>
> When migrating to 7.0.0, I wanted to do things right, using
>
>
>
> No matter whether I replaced the latter two by providedCompile as well or
> not, I got an error, obviously while trying to serialize the response to my
> POST (probably while trying to serialize the response content of type
> Long):
>
>
>
> Is there anything special to note about that JAX-RS library? Using my old
> Gradle config with the new TomEE release doesn't help either, so for the
> moment I'm stuck with 1.7.4.
>
> Thanks in advance for any hint.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JsonGenerationException after migrating to 7.0.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Johnzon doesnt filter these types, you can add it to the exclusion
configuring ConfigurableJohnzonProvider in openejb-jar.xml but the best
alternative is to set the right response type to TEXT_PLAIN instead of JSON.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-05-31 15:25 GMT+02:00 tam <ta...@tamatzner.de>:

> It's a Long. With the old libraries I used, this is put into the response,
> and neither client nor server complain because it's not JSON. Firebug tells
> me the response header says
>
> Content-length 3,
>
> Content-Type application/json,
>
> and the content is 101.
>
> Admittedly, that's not JSON, but why did the old libraries I used accept
> that and the new ones don't?
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678688.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JsonGenerationException after migrating to 7.0.0

Posted by tam <ta...@tamatzner.de>.
It's a Long. With the old libraries I used, this is put into the response,
and neither client nor server complain because it's not JSON. Firebug tells
me the response header says

Content-length 3,

Content-Type application/json,

and the content is 101.

Admittedly, that's not JSON, but why did the old libraries I used accept
that and the new ones don't?



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tp4678684p4678688.html
Sent from the TomEE Users mailing list archive at Nabble.com.