问题
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