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

Pops
  • 30,199
  • 37
  • 136
  • 151
schoenk
  • 824
  • 3
  • 13
  • 31
  • 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? – Display Name is missing Apr 17 '14 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 – JoseK Apr 18 '14 at 07:03

3 Answers3

7

Use one of follwing options in weblogic.xml descriptor:

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

Details are described here.

Blekit
  • 663
  • 4
  • 7
  • 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. – schoenk Apr 17 '14 at 11:41
  • According to [this](http://docs.oracle.com/cd/E24329_01/web.1211/e24368/classloading.htm#i1097083) 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? – Blekit Apr 17 '14 at 12:26
  • 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. – schoenk Apr 17 '14 at 14:12
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.

ralferic
  • 21
  • 1
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.

  • I now managed to move my code into WEB-INF/lib and so I could use the 'prefer-webinf-classes' property. – schoenk Apr 25 '14 at 15:08