1
votes

I am faced with a puzzle around some classloading issues with my application in Weblogic. There are some places in my code where there are classes which depend on classes from other jars and I must be missing something fundamental.

From reviewing information I can find, this shouldn't be a problem if both jars are on the classpath, but this seems to be more subtle in a Java EE application context on Weblogic.

I have an Ear, MyApp.ear

MyApp.ear contains several webapps (war) and a whole bunch of utility jars and EJBs. Structure is something like this ( I don't control it).

MyApp.ear
     MyWebApp.war
     UtilJar1.jar
     UtilJar2.jar
     etc...

Let's say that there are classes in UtilJar1 that import classes from UtilJar2. What MANIFEST.MF should specify that both jars should be on the classpath? The EAR's? The Webapp's? UtilJar1's?

From trial and error (Weblogic 10.3.2), the only way that this seems to work is if UtilJar2 is defined in the Manifest class-path of UtilJar1. But I would have thought that in the context of a webapp that the webapp's classpath would be used for any classloading happening in that webapp? Instead I see NoClassDefFound unless the second jar is specified in the classpath of the first.

1

1 Answers

0
votes

Below is an excerpt from oracle documentation:

The J2EE specification provides the manifest Class-Path entry as a means for a module to specify that it requires an auxiliary JAR of classes.

You only need to use this manifest Class-Path entry if you have additional supporting JAR files as part of your EJB JAR or WAR file.

Please go through the Manifest Class-Path section in the below documentation -

Class Loading

J2ee deployment archive [EAR] is an assembly of different modules with each module declaring there dependencies in there respective manifest files.

As per my understanding, each module [ war, ejb,jar] inside EAR will have there own class loaders which are children to EAR class loader. And child class loaders will have visibility of their parents only and are unaware of the sibling class loaders unless you declare the dependencies in Manifest file.

enter image description here

Even though there is an entry in WAR manifest, utilit1.jar is unaware of utility2.jar and you have to explicitly mention the dependency in Manifest file of Utility1.jar.