users@jersey.java.net

[Jersey] Re: Jersey with Jackson for JSON

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Fri, 17 Jun 2011 10:49:38 +0200

Hi,

Even when Jersey pulls in the Jackson JSON providers jar, Jersey
should keep using the old JAXB based JSON processing approach
for backwards compatibility reasons.

There is a special feature to turn Jackson JSON providers on.
See [1] for details.

If the above mentioned backwards compatibility is broken just
by upgrading Jersey, that that is definitely a bug and i am curious
what kind of setup triggers that. We use Maven for dependency management
throughout all our infrastructure and we did not experience any issue
in this area. What is you project setup? I have already heard form other
people Jackson became the default after upgrading Jersey, but
never got a reproducible test case. Any idea.

Message body worker lookup works such that application provided
workers take precedence. But other than that, as you write, the first one
found, which is capable of processing the actual data is picked up and used.
If the Jackson jars on your class-path contain
META-INF/services/javax.ws.rs.ext.MessageBody(Reader|Writer)
then it is likely, the Jackson providers are selected.

When using maven dependency mechanism,
only jackson-jaxrs.jar is pulled into the class-path, and that jar
does not contain the above described registration files.

Regarding Jackson configuration, you can provide your custom object mapper
where you configure Jackson the Jackson way. See example [2] for details
on this.

HTH,

~Jakub

[1]http://jersey.java.net/nonav/documentation/latest/json.html#d4e901
[2]http://download.java.net/maven/2/com/sun/jersey/samples/jacksonjsonprovider/1.7/jacksonjsonprovider-1.7-project.zip

On 06/16/2011 12:29 AM, charlesk wrote:
> Hi,
> I have some general question about how Jersey uses JSON serializers.
>
> I've just upgraded to jersey 1.4 and noticed that it pulls the
> jackson-jaxrs.jar (which contains the jackson providers) making Jersey to
> use Jackson for JSON serialization.
>
> By doing this, configuration options using JSONConfiguration class along
> with most of the classes in jersey-json.jar no longer works or applicable.
> By excluding the jackson-jaxrs.jar brings back the jettision JSON lib.
>
> My first question is that is this the recommended way for registering the
> providers? It seems like when multiple providers are deployed, it picks the
> first one that it encounters.
>
> Next question is that is there any plan to provide similar configuration
> options in Jackson through Jersey? Or is it left to Jackson to deal with
> this.
>
> Thanks
>
>
>
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Jersey-with-Jackson-for-JSON-tp6480924p6480924.html
> Sent from the Jersey mailing list archive at Nabble.com.
>