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

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

问题描述

CXF JAX-RS应用程序我使用jackson将POJO编组为JSON。这在很大程度上是有效的,但是有一天,它在编组一个深度嵌套的对象时失败了。



经过一些调查后,我发现杰克逊被纳入Glassfish 3(通过Jersey)和删除 jackson-core-asl.jar,jackson-jaxrs.jar,jackson-mapper-asl.jar jackson -xc.jar 一切都很好用。我猜杰克逊1.7.1(包含在GF3中)有一些bug在我的应用程序(1.8)附带的版本中得到修复。

现在问题是,为什么我甚至必须首先做这件事?我会认为包含在我的war文件中的库应该优先于Glassfish的 / modules 目录中的任何库。



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



在附注中,GF2容器仍存在问题,但找不到任何在 / lib 文件夹中(不存在 / modules 文件夹,就像GF3一样)中的jackson库。任何关于杰克逊可能隐藏在GF2中的线索(如果有的话)? 解决方案

告诉Webapp类加载器



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

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

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


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.

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).

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.

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 ...

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)?

解决方案

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

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

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

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

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

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