views:

59

answers:

2

We're trying to use Jackson 1.5 to take advantage of some of the polymorphic handling it offers, but it appears that Jersey brings along it's own outdated version of Jackson (1.1.1). When testing Jersey serialized JSON, we get different results than when we serialize by hand in unit tests.

{"id":"40","ticketProps":[{"id":"28","field":{"id":"28","name":"WXYZ","strict":"false","valueType":"STRING"},"value":"W"},{"id":"29","field":{"id":"29","name":"SEAT","strict":"false","valueType":"STRING"},"value":"4A"}]}

{"id":"40","ticketProps":[{"id":"28","field":{}},{"id":"29","field":{}}],"name":null}

Unfortunately using Jackson 1.1.1 is not an option. Is there any way to get Jersey to use Jackson 1.5? Was thinking of trying to set it in the Jersey Config class or something...

+1  A: 

If the maven POM for Jersey does not allow you to separate the Jackson dependency from the Jersey dependency, then you could get hold of the individual JARs manually, swapping out the Jackson 1.5.x JAR(s) for the 1.1.x one.

Note that there's no guarantee that Jersey will work with the newer Jackson version. Jackson's API changed quite a lot around the 1.1 releases.

skaffman
There is a reasonable chance it would still work, as theoretically 1.x minor versions should be backwards compatible. But it is true that there have been cases where accidental incompatibilities were introduced. And Jersey also uses some lower level access which is bit riskier wrt compatibility.
StaxMan
A: 

You didn't give much details (especially about your runtime environment) so I'll just cover the maven part of the question: declare the version 1.5 of Jackson under the dependencyManagement section to force the convergence in other dependencies having jackson as dependency.

Wheter this will work at runtime is left as an exercise for the reader :)

For the record, here is what we can read in the V3.1JerseyOnePager:

Jersey is currently using Jackson 1.1 in GlassFish 3.0. The version will be upgraded in 3.1 to the latest stable version (currently 1.5.2).

Pascal Thivent
Maven2, Netbeans, Jersey, JPA, Glassfish for testingSo that leads me to believe that the Jackson dependency is wrapped in Glassfish, not Jersey. Oh perhaps it is some limitation of Glassfish. That sound correct?
gmoore
@gmoore: Limitation? You're maybe just expecting too much (AFAIK, GlassFish is spec compliant). But maybe you could bundle Jersey and Jackson in your war and tell GlassFish to use the libs of you war first (in the sun-web.xml) instead of the one provided by GlassFish.
Pascal Thivent
I meant limitation in that Glassfish/Jersey works with Jackson 1.1.1 and wouldn't play nice with a sudden upgrade to New Awesome Version.
gmoore