4

I am migrating a JAX-RS application from WebSphere 8.0 to WebSphere Liberty 8.5.5.

In WebSphere 8.0, Jackson was provided by WebSphere. I can find jackson-core-asl-1.9.12.jar, jackson-jaxrs-1.9.12.jar, jackson-mapper-asl-1.9.12.jar and jackson-xc-1.9.12.jar files in the AppServer\plugins\ directory.

In the new application server (WebSphere Liberty), I get the following exception: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "myPropertyName". I think that this exception happens because the annotation @JsonIgnoreProperties(ignoreUnknown = true) on the serialized classes does not work. My guess is that it happens because WebSphere Liberty 8.5.5 provides an older version of Jackson.

I tried to deploy the version of Jackson which I need with my application, but it did not help (I still have exceptions). How can I make WebSphere Liberty use the version of Jackson that I need?

1
  • Hello, I know the accepted answer is correct and works. But could you please update question with steps mentioning which all jars do I have to include in shared library to make use of JACKSON2.2. May 30, 2018 at 6:33

3 Answers 3

4

WebSphere Liberty will use the version of Jackson you specify with JAX-RS 2.0, with a few caveats (which we are chasing).

A) You still have to specify JSON providers explicitly.

B) You may see an NPE with 16.0.0.2 as described here: Regiser JacksonJsonProvider in Websphere liberty profile. We've worked around that as described. The most recent beta doesn't exhibit this behavior, which suggests the next runtime update won't either.

Examples: https://github.com/gameontext/gameon-mediator/blob/6b469d18965673af35129abf3ff987b61af54c88/mediator-app/src/main/java/org/gameontext/mediator/JaxbJsonProvider.java

and

https://github.com/gameontext/gameon-mediator/blob/6b469d18965673af35129abf3ff987b61af54c88/mediator-app/src/main/java/org/gameontext/mediator/JsonProvider.java

Our gradle build brings in the jackson dependency: https://github.com/gameontext/gameon-mediator/blob/6b469d18965673af35129abf3ff987b61af54c88/mediator-app/build.gradle

And our server.xml uses jaxrs-2.0, but doesn't do any classloader magic: https://github.com/gameontext/gameon-mediator/blob/6b469d18965673af35129abf3ff987b61af54c88/mediator-wlpcfg/servers/gameon-mediator/server.xml

HTH

2
  • Thanks, everything works after I specified JAX-RS JSON provider explicitly, and put objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false) in it. I removed @JsonIgnoreProperties(ignoreUnknown = true) annotations. I did not have to change the version of the library.
    – Alexey
    Sep 10, 2016 at 7:12
  • Excellent! Very glad to know this works for you, too.
    – ebullient
    Sep 11, 2016 at 2:54
2

Yes, WebSphere Liberty uses an older version of Jackson than traditional WAS. We'll need to get that fixed!

In the mean time, one other possibility for you would be to use the jaxrs-2.0 feature and then include the newer version of Jackson in your application or shared library.

One of the differences between Liberty's jaxrs-1.1 and jaxrs-2.0 features is that jaxrs-2.0 does not expose the Jackson API packages. So the application's classloader would not be able to load the Jackson classes that ship with Liberty. That means that it would load the classes from your application without needing to do parentLast delegation or other classloader tricks.

Hope this helps, Andy

2
  • I am using the jaxrs-2.0 feature in server.xml. And it looks like I have Jackson 1.6.2 on classpath at runtime (provided by Liberty!).
    – Alexey
    Sep 10, 2016 at 7:18
  • I found another solution to my problem, but, perhaps, if I switched to Jackson 2.x, it would solve the problem.
    – Alexey
    Sep 10, 2016 at 7:19
1

Alexey, have you tried a parentLast loader approach to the application deployed on liberty so that application classes can take precedence. You can reference this question to get more insights. There is documentation for that from IBM as well here

2
  • Thanks! I'll have a look at that question.
    – Alexey
    Sep 8, 2016 at 11:02
  • Essentially in your application EAR packaging , you will have to mention that you want parent last (to indicate your packaged libraries are to be considered and not the default ones loaded by the class loader) Sep 8, 2016 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.