问题
prefer-web-inf-classes has to be specified for the classes specified in Web-INF to take precendence over classes present in application library of weblogic server. I have a special case where I need the class loader to use one specific jar from WEB-INF folder. Is there any way of doing this?
回答1:
You may want to look at Filtering Classloaders?
This allows to specify on a package-by-package level just which classloader to use.
You want to be very careful with this, though. Are you sure you already are in CLassloader Hell, so you must resort to this kind of stuff, and there's really no alternative?
Did you consider putting the JAR into the APP-INF/lib folder of your EAR? Or move "all but the one you need in WEB-INF/lib" out to APP-INF/lib?
回答2:
To prefer all packages which are in your WEB-INF/lib over those which are bundled with your WebLogic lib set <prefer-web-inf-classes> to true in your weblogic.xml or application-weblogic.xml.
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
For more detail see Using a Filtering Classloader, weblogic.xml Deployment Descriptor Elements and WebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis Tool .
If you are not sure if the right class is loaded you can use the Classloader Analysis Tool for WebLogic.
回答3:
If you are using Weblogic 10.3.4+ version. You can use prefer-application-packages to control class level preference loading. Take a look at this video for more details.
来源:https://stackoverflow.com/questions/8166580/weblogic-configuration-prefer-web-inf-classes