Loading Websphere Classes

We have an application deployed on the Websphere 7 application server. Its deployment and operation in various environments. But it gave a method of not found exception in one new env. Upon deepening, we found that a certain class was present in 2 jars, and the class from the "wrong" jar was loaded into the new env. I looked at the detailed view of the class loader, and the can loading sequence was different in it.

In further research, it would seem that there was a random variance in the order in which the jar files were uploaded to each env.

2 questions:

1) What coefficient determines the policy for loading WAS classes and any suggestion to fix the problem?

2) More generally, when we indicate, assuming * .jar in the classpath for any java program, how does any JVM load jars? How is it in alphabetical order or according to the modified time or any such file?

+4
source share
3 answers

When installing web applications under WAS, you can set the class loading policy in the parameters of this application (or globally at the server / node level)

If the policy settings (search) are "parent first" / "parent last" and one class loader for each application or for war. The default is parent first / war. If your web application comes with all banks, it will be better for you if the policy is set to "parent last / application". Also, if you edit your web.xml to reflect the changes, be sure to set "use binary configuration", otherwise it will always use what it stored during installation.

+8
source

Java loads the classes in the order in which they appear in the classpath. Therefore, if your class path is "c: \ jar1.jar; c: \ jar2.jar", and jar1.jar and jar2.jar contain the same class, the class from jar1.jar will always be used. If the order has been canceled, then the jar2.jar class will always be used.

Wikipedia explains how the Loaders class works pretty well http://en.wikipedia.org/wiki/Java_Classloader

The class path can be configured through the WAS admin console on the server under the server> Process Definition> Java Virtual Machine

It can also be customized for each application.

+1
source

You ask very big questions. To solve your problem there are 2 options:

  • go for PARENT LAST and add any version of JAR that you need for the classpath
  • stay with PARENT FIRST, but downgraded JARs are sent along with your application according to what WAS provides.
0
source

All Articles