简体   繁体   中英

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

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

Use one of follwing options in weblogic.xml descriptor:

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

Details are described here .

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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