简体   繁体   English

具有相同jar的Java类加载器

[英]Java classloader with same jar

I know that many subject speak about classpath loader and transitive dependancy but im little confused. 我知道许多主题都在谈论类路径加载器和可传递的依赖关系,但我几乎不感到困惑。

I m working on a legacy application that use spring 2.0.5 and spring-ws and all work fine from the beginning of the project to now. 我正在开发一个使用spring 2.0.5和spring-ws的旧应用程序,并且从项目开始到现在都可以正常工作。 And recently we are faced to a runtime problem with a an exception like methodnotfoundexception. 最近,我们面临一个运行时问题,并带有诸如methodnotfoundexception之类的异常。

In fact we see that spring-ws depend on spring-2.5. 实际上,我们看到spring-ws依赖于spring-2.5。 So maven transitive dependancy add spring 2.5 in my webinf/lib directory near spring 2.0.5 所以Maven传递依赖项在spring 2.0.5附近的我的webinf / lib目录中添加spring 2.5

But i dont understand why all working fine during many years and now why weblogic decide to load spring2.5 before spring2.0.5 and cause this error? 但是我不明白为什么多年以来所有功能都能正常工作,现在为什么Weblogic决定在spring2.0.5之前加载spring2.5并导致此错误?

We have correct the problem and now im looking for same jar with different version and do build failure when i have a conflit to avoid dependancy problem in the future. 我们已经纠正了问题,现在我正在寻找具有不同版本的同一个jar,并且当我为避免将来出现依赖问题而进行限制时,确实会导致构建失败。

But i just want to understand why weblogic decide to load one or another jar ? 但是我只想了解为什么weblogic决定加载一个或另一个jar? Because if its alphabetical order, same jar will be loaded all the time, but in my exemple the order change... So i don t understand clearly whats happened. 因为如果按字母顺序排列,则将始终加载相同的jar,但是在我的示例中,顺序会发生变化...因此,我不清楚发生了什么。

Thanks by advance;) 预先感谢;)

While it is documented that WEB-INF/classes is loaded before WEB-INF/lib , the documentation is not clear in cases like yours - where there are sibling copies of Spring in the WEB-INF/lib . 尽管有文件证明WEB-INF/classes之前加载WEB-INF/lib ,文件是不是在你们这样的情况下明确的-那里有在同级春天的副本WEB-INF/lib

In Tomcat it is alphabetical, but looks like Websphere, Jboss and Weblogic are random. 在Tomcat中,它是按字母顺序排列的,但看起来像Websphere,Jboss和Weblogic是随机的。 See https://stackoverflow.com/a/5817890/327426 参见https://stackoverflow.com/a/5817890/327426

From some threads on the Oracle forums, the recommendation is to run the Classloader Analysis Tool available at http://docs.oracle.com/cd/E23943_01/web.1111/e13706/classloading.htm#BABHJGJJ for your app and see the results. 从Oracle论坛上的一些话题中,建议您运行适用于您的应用程序的Classloader分析工具,该工具位于http://docs.oracle.com/cd/E23943_01/web.1111/e13706/classloading.htm#BABHJGJJ ,并参见结果。 This tool will identify classloading conflicts. 该工具将识别类加载冲突。

See similar issue at https://community.oracle.com/thread/2387921?tstart=0 https://community.oracle.com/thread/2387921?tstart=0上看到类似的问题

This post from 2009 http://www.coderanch.com/t/472496/BEA-Weblogic/Loading-order-jar-WEB-INF on Weblogic v9.2 states "Checking the logs I see the .jars in WEB-INF/lib are being loaded in reverse alphabetical order". 2009年http://www.coderanch.com/t/472496/BEA-Weblogic/Loading-order-jar-WEB-INF上有关Weblogic v9.2的帖子指出“检查日志,我在WEB-INF中看到.jars / lib以相反的字母顺序加载”。 This may or may not be true for your version 这对于您的版本可能适用,也可能不适用

Another option is to use Maven to bypass the transitive import being packaged in the WAR 另一个选择是使用Maven绕过打包在WAR中的可传递导入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM