users@jersey.java.net

[Jersey] Re: nil instead of null

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 27 Sep 2011 10:13:23 -0700

On Mon, Sep 26, 2011 at 7:14 AM, nbaliga <nbaliga_at_cleartrial.com> wrote:
> I did try using the 1.9 SNAPSHOT in my efforts to incorporate a Jackson
> provider in my Jersey project.
>
> However, and I double checked this morning, the root unwrapping feature
> doesn't work for me. I still get the Java name of the root variable instead
> of the XmlRootElement name attribute value.

This could happen if you do not use JAXBAnnotationIntrospector, but
when using it @XmlRootElement is the one that is used (or if not, it'd
be a bug, but I am pretty sure this is unit tested).

> I think this is a side effect of the fact that Jackson seems to be ignoring
> the JAXB annotations altogether, because the propOrder of the elements is
> also being ignored.

It definitely sounds like support for JAXB annotations was not enabled then.
And the problem is probably with this:

> // make serializer use JAXB annotations (only)
> objectMapper.getSerializationConfig().withAnnotationIntrospector(introspector );

which would not set the configuration, but only create a new config
object -- all "withXxx()" methods create a new immutable copy of
object they are called on, return that instance.

What you can do instead is just:

objectMapper.setAnnotationIntrospector(introspector);

which calls appropriate methods on both config objects etc.

-+ Tatu +-