16

In my application I am using Joda-Time 2.0 but in my WebLogic path there is library Joda-Time 1.2.

How can I change the order and tell WebLogic to use my library? Now it is using its own library, not mine. I just added a Maven project dependency to Joda-Time 2.0.

JodaStephen
  • 60,927
  • 15
  • 95
  • 117
hudi
  • 15,555
  • 47
  • 142
  • 246

2 Answers2

27

There are several ways of doing this.

  1. Change your startWeblogic.cmd(sh) in the bin folder for your domain, look for the classpath setting and add the new joda before any other WebLogic jars
  2. as was said above, you can change your weblogic.xml if the application is a web application and chose to prefer any lib that comes inside the war.
  3. If you are using an Enterprise application, you can set the following options in your weblogic-application.xml:

    <prefer-application-packages>
        <package-name>org.apache.*</package-name>
        <package-name>antlr.*</package-name>
    </prefer-application-packages>
    

And set your package name for joda in there.

Please note that the first option might result in strange behavior from WebLogic.

Note for some reason I can't get the code to work with the XML.

Steven Benitez
  • 10,936
  • 3
  • 39
  • 50
Nuno Furtado
  • 4,548
  • 8
  • 37
  • 57
  • thx for another solution but the first one is more elegant and it works but thx anyway – hudi Aug 25 '11 at 10:12
  • 1
    note that it has nothing to do with elegance. both options 2 and 3 might be needed depending on your project specifics. JoseK does work for the web container, but it will fail if you need it in your ejb container. But if it works for you, it is the solution you were looking for – Nuno Furtado Aug 25 '11 at 10:48
  • +1 on this one; option 2 includes the other answer itself and option 3 is my preferred way to go as it lets you specify which libraries get loaded at the application-level. Using prefer-web-inf-classes is an all-or-nothing approach and will cause lots of duplication when loading libs that would otherwise be shared at the server-level. – CashIsClay Aug 25 '11 at 13:56
  • yea you are right when I set true to preffer all package there was throw another exception so I used just joda time and everythink works fine thx a lot – hudi Aug 25 '11 at 22:04
  • Option 3 Must be inside of this tag as said in the reference https://docs.oracle.com/cd/E24329_01/web.1211/e21049/weblogic_xml.htm#WBAPP659 – André Luís Tomaz Dionisio Feb 06 '20 at 08:39
12

As your class is present in your war, WEB-INF/lib,

can you try using the weblogic.xml setting to force the WEB-INF/lib class to get loaded in preference to that in server/lib with

<container-descriptor>     
<prefer-web-inf-classes>true</prefer-web-inf-classes>   
</container-descriptor> 
JoseK
  • 31,141
  • 14
  • 104
  • 131