我如何处理 Glassfish 包含的库与应用程序提供的库崩溃? [英] How do I deal with Glassfish included libs crashing with application supplied libs?

查看:15
本文介绍了我如何处理 Glassfish 包含的库与应用程序提供的库崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的 CXF JAX-RS 应用程序使用 jackson 将 POJO 编组为 JSON.这在大多数情况下有效,但前几天在编组深度嵌套的对象时它因 NPE 失败.

A CXF JAX-RS application I have uses jackson to marshal POJOs to JSON. This works for the most part, but the other day it failed with a NPE when marshalling a deeply nested object.

经过一番调查,我发现 Jackson 包含在 Glassfish 3(通过 Jersey)中,并且在删除了 jackson-core-asl.jar、jackson-jaxrs.jar、jackson-mapper-asl.jar 之后jackson-xc.jar 一切正常.我猜 Jackson 1.7.1(包含在 GF3 中)有一些错误,在我的应用程序 (1.8) 附带的版本中已修复.

After some investigation I found out that Jackson was included in Glassfish 3 (through Jersey) and after removing jackson-core-asl.jar, jackson-jaxrs.jar, jackson-mapper-asl.jar and jackson-xc.jar everything worked beautifully. I guess that Jackson 1.7.1 (included in GF3) had some bug that was fixed in the version shipped with my application (1.8).

现在的问题是,为什么我一开始就必须这样做?我原以为包含在我的 war 文件中的库应该优先于 Glassfish 的 /modules 目录中的任何库.

Now the question is, why did I even have to do this in the first place? I would have thought libraries that are included in my war files should take presedence over any libraries in Glassfish's /modules directory.

有没有比从应用服务器中删除 jar 更简洁的方法呢?也许还有其他应用程序依赖于这些 jar ......

Is there a cleaner way to do this than removing jars from the app server? Maybe there are other applications that depend on these jars ...

顺便说一句,问题仍然存在于我们的 GF2 容器中,但我在 /lib 文件夹中找不到任何 jackson 库(没有 /modules文件夹就像在GF3中一样).关于杰克逊可能藏在 GF2 的什么地方的任何线索(如果有的话)?

On a side note, the problem still exists with our GF2 container, but I cannot find any jackson libraries in the /lib folder (there is no /modules folder like in GF3). Any clues on where Jackson might be hiding in GF2 (if at all)?

推荐答案

告诉 Webapp 类加载器更喜欢您的 WAR 提供的 JAR.

Tell the Webapp classloader to prefer JARs provided by your WAR.

添加您的 WEB-INF/sun-web.xml(或 WEB-INF/glassfish-web.xml):

Add in your WEB-INF/sun-web.xml (or WEB-INF/glassfish-web.xml):

...
<class-loader delegate="false"/>
...

参见 http://jersey.java.net/nonav/documentation/latest/glassfish.html#d4e1927

这篇关于我如何处理 Glassfish 包含的库与应用程序提供的库崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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