如何在JAX-RS应用程序中更改Jackson版本(WebSphere Liberty) [英] How to change Jackson version in JAX-RS app (WebSphere Liberty)

查看:162
本文介绍了如何在JAX-RS应用程序中更改Jackson版本(WebSphere Liberty)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将JAX-RS应用程序从WebSphere 8.0迁移到WebSphere Liberty 8.5.5。

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

在WebSphere 8.0中,Jackson由WebSphere提供。我可以找到 jackson-core-asl-1.9.12.jar jackson-jaxrs-1.9.12.jar jackson-mapper-asl-1.9.12.jar jackson-xc-1.9.12.jar 中的文件 AppServer \plugins \ 目录。

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.

在新的应用程序服务器(WebSphere Liberty)中,我得到了以下异常: org.codehaus.jackson.map.exc.UnrecognizedPropertyException:无法识别的字段myPropertyName。我认为发生此异常是因为序列化类上的注释 @JenIgnoreProperties(ignoreUnknown = true)不起作用。我的猜测是因为WebSphere Liberty 8.5.5提供了旧版本的Jackson。

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.

我试图用我的应用程序部署我需要的Jackson版本,
但它没有帮助(我仍然有例外)。如何让WebSphere Liberty使用我需要的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?

推荐答案

WebSphere Liberty将使用您指定的Jackson版本使用JAX-RS 2.0,有一些注意事项(我们正在追逐)。

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

A)您仍然必须明确指定JSON提供程序。

A) You still have to specify JSON providers explicitly.

B)您可能会看到如此处所述的16.0.0的NPE: Regiser JacksonJsonProvider in Websphere liberty profile 。我们已经如上所述解决了这个问题。最新的测试版没有出现此行为,这表明下一次运行时更新也不会。

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.

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

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

我们的gradle构建带来了jackson依赖:
https://github.com/gameontext/gameon-mediator/blob/6b469d18965673af35129abf3ff987b61af54c88 /mediator-app/build.gradle

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

我们的server.xml使用jaxrs-2.0,但不执行任何类加载器魔术:
https:// github。 com / gameontext / gameon-mediator / blob / 6b469d18965673af35129abf3ff987b61af54c88 / mediator-wlpcfg / servers / gameon-mediator / server.xml

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

这篇关于如何在JAX-RS应用程序中更改Jackson版本(WebSphere Liberty)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆