Search code examples
javaclasswebsphereclassloader

How Does WebSphere Choose the Classloading Order in a Folder (WEB-INF/lib)


I am currently facing an interesting problem where our application fails to start up on 3/4 nodes due to classloading issues.

The problem seems to be that WAS is loading b.jar before a.jar. After troubleshooting more, I found that all of the nodes load the jars in different orders (via Classpath viewer in console) and the working node may have just been a fluke.

How does WebSphere determine the classloading order within an installed applications WEB-INF/lib folder?


Solution

  • Order of loading jars is undefined in websphere. To solve your problem I can suggest you to use one of the below option.

    Use manifest classpath settings by mentioning the jar names in a order like how you want them to be loaded.

    OR

    You can extract the classes from a.jar and put it in the WEB-INF/classes directory. Then remove a.jar from the lib folder. Because classes directory will be loaded before lib directory.