Prevent Glassfish from using its own versions of libraries instead of those in a project

喜你入骨 提交于 2019-12-05 02:00:00

问题


Glassfish has whole bunch of third-side libraries stored in its modules directory. To my surprise, if my project uses a library which is present there, Glassfish will provide it from there, instead of the right version I have packed-in in my WAR file.

This leads to a number of errors. For example, I use jackson-datatype-joda version 2.6.3, which requires jackson-databind with same version, and it is included in my project. But Glassfish replaces that package with version 2.3.2, which leads to this issue.

How can I prevent Glassfish (4.1) from replacing the libraries I use with another versions?


回答1:


Add a glassfish-web.xml file to your WEB-INF directory containing something like,

<glassfish-web-app>
  <class-loader delegate="false" />
</glassfish-web-app>

This will ensure classes are loaded from your war before the server classpath



来源:https://stackoverflow.com/questions/35403919/prevent-glassfish-from-using-its-own-versions-of-libraries-instead-of-those-in-a

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