3

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

2
  • Instead of adding it to the domain lib folder, have you tried editing setDomainEnv.sh or startWebLogic.sh and putting the new jar on the classpath? Have you tried going to the Server Start tab in the admin console and changing the classpath there? Commented Apr 17, 2014 at 15:06
  • I dont think Weblogic allows this. the idea is if you need a library over whats system - then you'll have to bundle it within your web app or EAR and then use the solution @Blekit has Commented Apr 18, 2014 at 7:03

3 Answers 3

7

Use one of follwing options in weblogic.xml descriptor:

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

Details are described here.

Sign up to request clarification or add additional context in comments.

3 Comments

This does only work with JARs provided within the applicaton ('WEB-INF/lib' or 'APP-INF/lib') but not with JARs provided in the domain lib folder.
According to this article, "domain /lib classloader will be the parent of any Java EE application", so it should work out of the box. Maybe try using the Java EE libraries feature?
Yes, "domain/lib" is a parent of the EE application class loader, but the article also says that it is a child of the overall system class loader. And that is my problem. I would need some kind of "prefer" config for the "domain/lib" classes.
2

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.

Comments

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.

1 Comment

I now managed to move my code into WEB-INF/lib and so I could use the 'prefer-webinf-classes' property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.