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/06/01 07:49:04 UTC

Johnzon - bugs or features?

I made the following observations during the migration to 7.0.0, caused by
the change to Johnzon for JAXB. I am curious whether these are intentional,
still bugs, or my fault:

Modifying JAXB annotations


It appears to me that modifications in my JAXB annotations (like
@XmlRootElement) only take effect after restarting the server.
Auto-deploying won't notice those changes. (Although it notices other
annotation changes like javax.ws.rs.) Just reloading the app via the TomEE
manager console doesn't work either. Is there a way to have those
annotations processed at every deployment?

JAXB annotations in inner classes


For small JAXB-annotated DTOs that are only relevant for one web service
operation, I'd like to define them as inner classes of the class using them.
However, JAXB annotations appear not to be processed in an inner class. Is
that right?

Getters and setters of JAXB annotated classes


Even if I declare @XmlAccessorType(XmlAccessType.FIELD), it appears that
JAXB annotations only take effect if the class has getters and setters. (I
didn't try with getters only or setters only.) In particular for the
aforementioned DTO classes, these are superfluous. Any way to do without
them?

Nested objects don't get serialized


An attribute



where A is also JAXB annotated, doesn't lead to a nested JSON structure, no
matter whether I put @XmlElement or @XmlElementWrapper in front or not. (I
also tried with List instead of Set.) Are there any limitations yet, or any
not yet documented annotations to write?

Documentation of available options and their (de)serializing effect


The change in wrapping (discussed in
http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tc4678684.html)
and the failure concerning nested objects makes me suspicious of that
Johnzon thing. How are we to know what it accepts and how it reacts to which
annotation if it's nowhere documented? (The "documentation" in
http://johnzon.apache.org/ is a joke.) Unless there exists complete and
reliable documentation of such a library, it should be thrown out of the
application server, as it's obviously not mature yet for production
environments.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Johnzon - bugs or features?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-06-01 12:33 GMT+02:00 tam <ta...@tamatzner.de>:

> Still confused. I want to map java POJOs 1-1 to JSON, and in fact I've been
> doing it all the time. (I learned all that stuff a while ago using
> Jackson.)
> Looking at Jackson's docs on
> http://wiki.fasterxml.com/JacksonJAXBAnnotations and Genson's on
> https://owlike.github.io/genson/, they both claim to use JAXB annotations.
> So if Johnzon works like those, why would it ignore the annotations?
>
>
Hehe, For both JAXB is not the main API but something added.


> Anyway, it's sort of running now, but the problems I described are still
> present: No nested objects, and endless fiddling around before it actually
> serialized. Don't ask me what I did wrong, but around 50 times it just gave
> me lists of empty objects like [{}, {}, {}...]. (But the right number of
> objects, so at least it recognized them.)
>
>
Looks like properties are not accessible (POJO standard meaning)


> BTW I didn't want to hurt anyone's feelings. It's just when I see in the
> Maven Repository that something is announced as incubating and alpha, and
> documentation is sparse, I get the message that it's not finished yet. I'd
> also prefer to belong to the happy crowd who's using it without problems;
> I'm just lacking information to get happy too.
>
>
>
Well the confusion is quite common but incubating is not about code but
linked to Apache community. Documentation is for sure not very verbose but
help is welcomed and I think you are one of the most accurate person to do
that at the moment cause you are the first one really getting issues. If
you are interested just contact us on johnzon list and we'll help you to
work on the doc.


>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708p4678716.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Johnzon - bugs or features?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le 11 juin 2016 18:01, "Steve Goldsmith" <sg...@gmail.com> a écrit :
>
>
https://repository.apache.org/content/groups/snapshots/org/apache/johnzon/apache-johnzon
>
> I've had several Johnzon issues over the months using TomEE 7. Typically
> you just need to drop the latest incubating jars into TomEE lib dir.
Romain
> knows of the issues (most of the time) and can direct you to the
corrective
> action.
>
> On Sat, Jun 11, 2016 at 11:10 AM, tam <ta...@tamatzner.de> wrote:
>
> > Technically, the Johnzon list is certainly the place to discuss that
stuff.
> > So let's discuss further points there. I see two lists on the Johnzon
site,
> > a commits list and a developer list. Both appear to be used mostly by
the
> > development team and not contain questions of users like me. Which of
them
> > (or what else) should I use?
> >

Dev one.

> > Still, I think the topic has a TomEE aspect as well. When a library
> > included
> > with TomEE is replaced by something that causes considerable effort and
> > uncertainty (e.g. because it uses different annotations, is scarcely
> > documented, behaves unpredictably, ...), this is a drawback for TomEE
> > itself. A user might not even be aware which of the dozens of libraries
is
> > responsible for a certain misbehavior (e.g. if it doesn't throw an
> > exception
> > but just doesn't work in the expected way).
> >

Same if you put jpa annotations for a jaxb model. Today we got more
positive feedbacks than negatives to be honest. We also always fixed bugs
fast. So here is the thing: we are open source, not owned by a company so
you are happy or you contribute - reporting a big with a testcase is
awesome - or you find a company happy to do the fixes you want.

Last note: you can change the provider in tomee and nobody forces you to
use tomee if that is a that bad server....

> > Both the Johnzon download page and Maven appear only to offer 0.9.3. Is
> > 0.9.4 available somewhere?
> >

Not yet. We are waiting some infrastructure work to release the graduated -
no more incubating -binaires.

> >
> >
> > --
> > View this message in context:
> >
http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708p4678849.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>
>
>
> --
> Steven P. Goldsmith

Re: Johnzon - bugs or features?

Posted by Steve Goldsmith <sg...@gmail.com>.
https://repository.apache.org/content/groups/snapshots/org/apache/johnzon/apache-johnzon

I've had several Johnzon issues over the months using TomEE 7. Typically
you just need to drop the latest incubating jars into TomEE lib dir. Romain
knows of the issues (most of the time) and can direct you to the corrective
action.

On Sat, Jun 11, 2016 at 11:10 AM, tam <ta...@tamatzner.de> wrote:

> Technically, the Johnzon list is certainly the place to discuss that stuff.
> So let's discuss further points there. I see two lists on the Johnzon site,
> a commits list and a developer list. Both appear to be used mostly by the
> development team and not contain questions of users like me. Which of them
> (or what else) should I use?
>
> Still, I think the topic has a TomEE aspect as well. When a library
> included
> with TomEE is replaced by something that causes considerable effort and
> uncertainty (e.g. because it uses different annotations, is scarcely
> documented, behaves unpredictably, ...), this is a drawback for TomEE
> itself. A user might not even be aware which of the dozens of libraries is
> responsible for a certain misbehavior (e.g. if it doesn't throw an
> exception
> but just doesn't work in the expected way).
>
> Both the Johnzon download page and Maven appear only to offer 0.9.3. Is
> 0.9.4 available somewhere?
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708p4678849.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>



-- 
Steven P. Goldsmith

Re: Johnzon - bugs or features?

Posted by tam <ta...@tamatzner.de>.
Technically, the Johnzon list is certainly the place to discuss that stuff.
So let's discuss further points there. I see two lists on the Johnzon site,
a commits list and a developer list. Both appear to be used mostly by the
development team and not contain questions of users like me. Which of them
(or what else) should I use?

Still, I think the topic has a TomEE aspect as well. When a library included
with TomEE is replaced by something that causes considerable effort and
uncertainty (e.g. because it uses different annotations, is scarcely
documented, behaves unpredictably, ...), this is a drawback for TomEE
itself. A user might not even be aware which of the dozens of libraries is
responsible for a certain misbehavior (e.g. if it doesn't throw an exception
but just doesn't work in the expected way).

Both the Johnzon download page and Maven appear only to offer 0.9.3. Is
0.9.4 available somewhere?



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708p4678849.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Johnzon - bugs or features?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Very interesting feedback

Global side note: this should be done on johnzon list

Then few comments inline


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress 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-09 7:19 GMT+02:00 tam <ta...@tamatzner.de>:

> @sgjava: Thanks, I'll have a try. That supports my suspicion that that
> Johnzon thing is still immature and the 0.x-incubating numbering scheme
> might be taken seriously.
>
>
Well nested objects and generics support was let's call it "mid-supported"
in last release. This is a model discussion which needs code examples and
report (on johnzon list once again) but originally (when I created the
codebase) it was just not supported at all cause I wanted to encourage
simple models. With user feedback and other committers we started to
support it but on this area there is a real compromise between code
complexity (until now johnzon code is understandable by any java dev) vs
feature support (generics can go super far). 0.9.3 already had basic
support but 0.9.4 support was enhanced to match "not flat" models.


> @Romain: Spontaneously, I was in favor of providing some documentation
> myself. But after another frustrating week with TomEE 7 and that Johnzon
> thing, the old textbook wisdom came to my mind: Documenting an artefact can
> only be done by its developers. As long as documentation is lacking, a user
> like me can only guess about the properties of the artefact and therefore
> not give any valid advice to others.
>
>
Well this is one way to see things, the other is to see tests as
documentations and as soon as you are a java dev you can then write the
doc, committer or not. For johnzon that's typically the case and if you
want to write something about generics you can start by reading this test
https://github.com/apache/incubator-johnzon/blob/master/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/AdvancedGenericsTest.java
for instance.

Also don't forget when I say you are a good candidate to write the missing
doc it doesn't mean you have to do it alone. We would be very happy to
support and help you if anything is unclear or you don't find/understand
entry points.


> Examples: I have one POJO that gets properly serialized without any @Xml...
> annotations. It has private fields and public getters and setters. Other
> POJOs, also having private fields and public getters and setters, won't get
> serialized without any annotations. The "documentation" given in
> http://johnzon.apache.org/ shows a few lines creating a mapper for
> MySuperObject, followed by an explanation that now objects of MyModel will
> be serialized to JSON. What does MySuperObject have to do with MyModel? No
> one from the outside can shed light into this mess.
>
>
Without more info hard to diagnostic it. Only case I can think about is it
doesn't respect POJO standard cause of the visibility.


> There are three lines on JSON-B. The first of them says "not fully
> compliant". The third says "It fully reuses the JSON-B as API". Why
> "reuses"? Does it implement the API of JSON-B? If it implements it fully,
> why is it called "not fully compliant"? How should an outsider document
> where it is compliant and where not?
>
>
This means we are not able - organizationnally - to pass jsonb TCK from
Oracle but if you use johnzon as a JSONB API we - for now, will likely be
enhanced depending the user feedback - ignore johnzon mapper API.


> I'm also wary of the @JohnzonIgnore, @JohnzonConverter, and
> @JohnzonProperty
> annotations. Lots of efforts are made in the JEE world to standardize
> interfaces and make our code independent of the implementation of an
> interface. Should I actually clutter my code with library specific
> annotations?
>
>
Well, yes and no. JavaEE 7 doesn't have any standard for JSON mapping. The
only one coming will be JSON-B in JavaEE 8 so until it gets out you will
have to use vendor annotations or rely on the defaults.

If you don't want to "clutter your code" what would you use then?


> Bottom line: It is nebulous which JEE standards that Johnzon thing
> implements to what degree. Until this is resolved, it should not be
> included
> in a (non-experimental) JEE container.
>
>
This part is very simple: today and for tomee Johnzon only implements the
only JSON standard: JSON-P 1.0 (same note as JSON-B cause of the legal
thing with Oracle) which is strictly speaking not something you have to
know really as a TomEE user.

Then you kind of need to know it for JAX-RS POJO mapping cause you always
need to customize few properties but keep in mind there is nothing in
JavaEE about that so not sure there is an alternative.


>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708p4678806.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Johnzon - bugs or features?

Posted by tam <ta...@tamatzner.de>.
@sgjava: Thanks, I'll have a try. That supports my suspicion that that
Johnzon thing is still immature and the 0.x-incubating numbering scheme
might be taken seriously.

@Romain: Spontaneously, I was in favor of providing some documentation
myself. But after another frustrating week with TomEE 7 and that Johnzon
thing, the old textbook wisdom came to my mind: Documenting an artefact can
only be done by its developers. As long as documentation is lacking, a user
like me can only guess about the properties of the artefact and therefore
not give any valid advice to others.

Examples: I have one POJO that gets properly serialized without any @Xml...
annotations. It has private fields and public getters and setters. Other
POJOs, also having private fields and public getters and setters, won't get
serialized without any annotations. The "documentation" given in
http://johnzon.apache.org/ shows a few lines creating a mapper for
MySuperObject, followed by an explanation that now objects of MyModel will
be serialized to JSON. What does MySuperObject have to do with MyModel? No
one from the outside can shed light into this mess.

There are three lines on JSON-B. The first of them says "not fully
compliant". The third says "It fully reuses the JSON-B as API". Why
"reuses"? Does it implement the API of JSON-B? If it implements it fully,
why is it called "not fully compliant"? How should an outsider document
where it is compliant and where not?

I'm also wary of the @JohnzonIgnore, @JohnzonConverter, and @JohnzonProperty
annotations. Lots of efforts are made in the JEE world to standardize
interfaces and make our code independent of the implementation of an
interface. Should I actually clutter my code with library specific
annotations?

Bottom line: It is nebulous which JEE standards that Johnzon thing
implements to what degree. Until this is resolved, it should not be included
in a (non-experimental) JEE container.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708p4678806.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Johnzon - bugs or features?

Posted by Steve Goldsmith <sg...@gmail.com>.
I had the nested object issue you had in some of the early Johnzon versions
included with TomEE. But it was only collections in the nested object that
would not deserialize. I ended up using 0.9.4-incubating-SNAPSHOT.

On Wed, Jun 1, 2016 at 6:33 AM, tam <ta...@tamatzner.de> wrote:

> Still confused. I want to map java POJOs 1-1 to JSON, and in fact I've been
> doing it all the time. (I learned all that stuff a while ago using
> Jackson.)
> Looking at Jackson's docs on
> http://wiki.fasterxml.com/JacksonJAXBAnnotations and Genson's on
> https://owlike.github.io/genson/, they both claim to use JAXB annotations.
> So if Johnzon works like those, why would it ignore the annotations?
>
> Anyway, it's sort of running now, but the problems I described are still
> present: No nested objects, and endless fiddling around before it actually
> serialized. Don't ask me what I did wrong, but around 50 times it just gave
> me lists of empty objects like [{}, {}, {}...]. (But the right number of
> objects, so at least it recognized them.)
>
> BTW I didn't want to hurt anyone's feelings. It's just when I see in the
> Maven Repository that something is announced as incubating and alpha, and
> documentation is sparse, I get the message that it's not finished yet. I'd
> also prefer to belong to the happy crowd who's using it without problems;
> I'm just lacking information to get happy too.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708p4678716.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>



-- 
Steven P. Goldsmith

Re: Johnzon - bugs or features?

Posted by tam <ta...@tamatzner.de>.
Still confused. I want to map java POJOs 1-1 to JSON, and in fact I've been
doing it all the time. (I learned all that stuff a while ago using Jackson.)
Looking at Jackson's docs on
http://wiki.fasterxml.com/JacksonJAXBAnnotations and Genson's on
https://owlike.github.io/genson/, they both claim to use JAXB annotations.
So if Johnzon works like those, why would it ignore the annotations?

Anyway, it's sort of running now, but the problems I described are still
present: No nested objects, and endless fiddling around before it actually
serialized. Don't ask me what I did wrong, but around 50 times it just gave
me lists of empty objects like [{}, {}, {}...]. (But the right number of
objects, so at least it recognized them.)

BTW I didn't want to hurt anyone's feelings. It's just when I see in the
Maven Repository that something is announced as incubating and alpha, and
documentation is sparse, I get the message that it's not finished yet. I'd
also prefer to belong to the happy crowd who's using it without problems;
I'm just lacking information to get happy too.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708p4678716.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Johnzon - bugs or features?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Reading your mail I suspect you miss the main point of johnzon which is to
map java model to json as 1-1 as do any other mapper (jackson, genson,
etc...).

This also means you can put all the JAXB annotations you want on your model
they will just get ignored by johnzon. Then I'm not sure if it is relevant
to answer your JAXB questions, assuming not.

About johnzon.apache.org: as mentionned we are finishing the migration to
the TLP and our site redeployment is not yet on the TLP domain so site is
not yet up to date (should be this or next week).
http://johnzon.incubator.apache.org/ is more up to date. It surely lacks
few things but explains the mapping. Feel free to do a PR on
https://github.com/apache/incubator-johnzon/blob/master/src/site/markdown/index.md
if you think anything is missing.

Side note: johnzon is in production since years without troubles cause it
just do what everyone asked when we had jettison which was not json
friendly at all. I understand that during a migration it can hurt (that
said nothing prevents you to add jettison in your app and get back the old
behavior) but this change has been smooth for a lot of people.



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:49 GMT+02:00 tam <ta...@tamatzner.de>:

> I made the following observations during the migration to 7.0.0, caused by
> the change to Johnzon for JAXB. I am curious whether these are intentional,
> still bugs, or my fault:
>
> Modifying JAXB annotations
>
>
> It appears to me that modifications in my JAXB annotations (like
> @XmlRootElement) only take effect after restarting the server.
> Auto-deploying won't notice those changes. (Although it notices other
> annotation changes like javax.ws.rs.) Just reloading the app via the TomEE
> manager console doesn't work either. Is there a way to have those
> annotations processed at every deployment?
>
> JAXB annotations in inner classes
>
>
> For small JAXB-annotated DTOs that are only relevant for one web service
> operation, I'd like to define them as inner classes of the class using
> them.
> However, JAXB annotations appear not to be processed in an inner class. Is
> that right?
>
> Getters and setters of JAXB annotated classes
>
>
> Even if I declare @XmlAccessorType(XmlAccessType.FIELD), it appears that
> JAXB annotations only take effect if the class has getters and setters. (I
> didn't try with getters only or setters only.) In particular for the
> aforementioned DTO classes, these are superfluous. Any way to do without
> them?
>
> Nested objects don't get serialized
>
>
> An attribute
>
>
>
> where A is also JAXB annotated, doesn't lead to a nested JSON structure, no
> matter whether I put @XmlElement or @XmlElementWrapper in front or not. (I
> also tried with List instead of Set.) Are there any limitations yet, or any
> not yet documented annotations to write?
>
> Documentation of available options and their (de)serializing effect
>
>
> The change in wrapping (discussed in
>
> http://tomee-openejb.979440.n4.nabble.com/JsonGenerationException-after-migrating-to-7-0-0-tc4678684.html
> )
> and the failure concerning nested objects makes me suspicious of that
> Johnzon thing. How are we to know what it accepts and how it reacts to
> which
> annotation if it's nowhere documented? (The "documentation" in
> http://johnzon.apache.org/ is a joke.) Unless there exists complete and
> reliable documentation of such a library, it should be thrown out of the
> application server, as it's obviously not mature yet for production
> environments.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Johnzon-bugs-or-features-tp4678708.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>