How to change Jackson version in JAX-RS app (WebSphere Liberty)

别来无恙 提交于 2019-12-01 22:35:45
ebullient

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

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!