2

Does somebody know in which order of precedence are the jars loaded?

Having several jars in WEB-INF/lib (in a war inside an ear in WAS 6.1).

Let's say aaa.jar, bbb.jar, ccc.jar. I have two different versions of a class paq1.paq2.paq3.MyClass inside aaa.jar and ccc.jar

The one inside ccc.jar is the correct one; the one in the aaa.jar is the wrong.

It seems that the wrong version is localized before the correct one.

Does somebody know what I have to do to guarantee that ccc.jar is loaded before aaa.jar?

(This is a simplification of a more real/complex problem, so renaming jars doesn't apply in this case).

Thank you in advance

JLLMNCHR
  • 1,551
  • 5
  • 24
  • 50
  • Why does this matter? (I'm curious.) – Paul Draper Dec 19 '13 at 10:20
  • 1
    possible duplicate of [Control the classpath ordering of jars in WEB-INF/lib on Tomcat 5?](http://stackoverflow.com/questions/2021227/control-the-classpath-ordering-of-jars-in-web-inf-lib-on-tomcat-5) – Mikhail Dec 19 '13 at 11:29
  • 1
    I don't think this is a duplicate as it's about a different hosting platform and the answers on the other question are specific to that platform. – Ganesh Sittampalam Dec 19 '13 at 20:54

3 Answers3

3

I don't believe the servlet specification guarantees any specific Classpath ordering for the jars in the lib-folder. Hence you are looking at vendor specific functionality or - even worse - vendor specific accidental behavior, which tends to be very brittle.

If the bad class is in your deployment, the cure is removing the bad class definitions from your deployment. I would suggest that your build procedure is responsible for this.

If the bad class is in WAS itself you can usually override it by putting jars in an extension folder in the server itself, not as part of your deployment.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • Agree except for the last paragraph. The WebSphere solution would be to change the classloader policy to PARENT LAST. Overriding classes deployed with WebSphere is likely to break something else. – dbreaux Dec 19 '13 at 23:39
1

JVM takes class from the first jar in class path, where appropriate class exists. All others are discarded. You can remove this jars from WEB-INF and put them directly to webserver's class path. But this will be ugly solution.

Mikhail
  • 4,175
  • 15
  • 31
0

WebSphere Application Server makes no guarantees about the ordering of JARs within WEB-INF/lib, and there is no option to force a particular ordering. I recommend removing duplicate classes and resources.

Brett Kail
  • 33,593
  • 2
  • 85
  • 90