How to prefer JARs from Weblogic domain over those from weblogic system

半世苍凉 提交于 2019-12-23 18:43:50

问题


I am using Weblogic Server 12.1.1 and copied some JARs to my domain's lib folder. One of the JARs is a org.apache.commons.io jar. Now I have the problem that Weblogic itself comes with a different version of commons-io in its system classpath and so I get NoSuchMethodErrors. Is there any way to configure Weblogic to prefer the libs from domain over those from Weblogic system?

The Filtering Classloader works only on those JARs provided with the application (WEB-INF/lib).


回答1:


If you need to put JARs into the domain /lib, I think you have to edit the setDomainEnv.cmd and modify PRE_CLASSPATH variable.

Example: set PRE_CLASSPATH=C:\myinstallation\Middleware\wlserver_12.1\domains\mydomain\lib\myjar.jar

But, if is possible to put JARs in WEB-INF/lib or APP-INF/lib, then use @Blekit solution, it's cleaner.




回答2:


Use one of follwing options in weblogic.xml descriptor:

  • prefer-application-packages
  • prefer-web-inf-classes

Details are described here.




回答3:


For completeness, i must say that putting commons-io into the domain/lib folder is a bad solution. The problem you describe is a good reason not to put widely used libraries into this folder. The problem might be circumvented by an even worse idea: moving that library higher up in the classloader hierarchy. If you insist on excluding commons-io from your application deliverables, you might install commons-io as an endorsed lib in the jdk. (see here) This would nail down your version of commons-io for every application including weblogic itself. Of course, this would be a problem if you need to contact weblogic support.



来源:https://stackoverflow.com/questions/23128846/how-to-prefer-jars-from-weblogic-domain-over-those-from-weblogic-system

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