nscappdev
asked on
ClassNotFoundException When Deploying EAR file that Refers to a WAR library on Weblogic
On my weblogic server(11g) I have a web appliation MyApp.ear, a library war file MyLib.war. Both deployed to the same managed server. MyLib.war is deployed as a shared library. MyEjb.jar is using classes located in MyLib.war - WEB-INF/classes. When I tried to deploy MyApp.ear, I got a CLASSNOTFOUND exception complaining the class in MyLib.war - WEB-INF/classes is not found.
I could see the class is indeed located in MyLib.war -> WEB-INF/classes folder.
I have tried to add the following in either weblogic-application.xml or weblogic.xml:
(MyLib is defined as EXTENSION name in MyLib.war's MANIFEST.MF).
What am I missing? There is no different version of jar files in MyApp.ear and MyLib.war.
The structure of the ear and war files:
MyApp.ear
META-INF
MANIFEST.MF
weblogic-application.xml
lib
APP-INF
MyEjb.jar
META-INF
MyWeb.war
META-INF
WEB-INF
weblogic.xml
web.xml
MyLib.war
META-INF
MANIFEST.MF
WEB-INF
classes
lib
weblogic.xml
weblogic.application.ModuleException: Exception preparing module: EJBModule(MyEjb.jar)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
org/my/lib/someclass.
....
caused by
Caused By: java.lang.ClassNotFoundException: org.my.lib.someclass
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
I could see the class is indeed located in MyLib.war -> WEB-INF/classes folder.
I have tried to add the following in either weblogic-application.xml or weblogic.xml:
<library-ref>
<library-name>MyLib</library-name>
<exact-match>false</exact-match>
</library-ref>
(MyLib is defined as EXTENSION name in MyLib.war's MANIFEST.MF).
What am I missing? There is no different version of jar files in MyApp.ear and MyLib.war.
The structure of the ear and war files:
MyApp.ear
META-INF
MANIFEST.MF
weblogic-application.xml
lib
APP-INF
MyEjb.jar
META-INF
MyWeb.war
META-INF
WEB-INF
weblogic.xml
web.xml
MyLib.war
META-INF
MANIFEST.MF
WEB-INF
classes
lib
weblogic.xml
Try something. In the weblogic console go to Deployments. Then click on the war file and set the "Deployment Order" to a value lower than the one you have in the "Deployment Order" of your ear file. Try this and if it does not work we can think of something else.
ASKER
Thank you for your reply girionis. I have already tried that. It didn't help.
From what I read about weblogic classloader hierarchy:
Just by adding the library-ref in the weblogic-application.xml should allow all the child classloaders of the application classloader to load the library. Seems like the class for the WAR isn't loaded anywhere.
I also verified that there are no reference jar version conflict in ear's lib and the library war file's lib.
What else could be the cause?
Thanks!
From what I read about weblogic classloader hierarchy:
The classloader implementation first checks its cache to see if the requested class has already been loaded. This class verification improves performance in that its cached memory copy is used instead of repeated loading of a class from disk. If the class is not found in its cache, the current classloader asks its parent for the class. Only if the parent cannot load the class does the classloader attempt to load the class. If a class exists in both the parent and child classloaders, the parent version is loaded.
Just by adding the library-ref in the weblogic-application.xml should allow all the child classloaders of the application classloader to load the library. Seems like the class for the WAR isn't loaded anywhere.
I also verified that there are no reference jar version conflict in ear's lib and the library war file's lib.
What else could be the cause?
Thanks!
It is possible that the MyLib.war is picked up by a different classloader. Can you make the MyLib.war file a jar and try again?
ASKER
MyLib.war needs other jars from its lib folder. If I just packed the classes in MyLib.war as a jar, I'm able to deploy MyApp.ear. Does that mean MyLib.war was picked up by another classloader??
However, packing it in a jar won't solve the problem because when MyLib is invoked from MyApp, it needs other jars that are in its own lib folder.
Also, I can't include MyLib.war in MyApp.ear as the war library is used by several other application deployed to the same managed server.
However, packing it in a jar won't solve the problem because when MyLib is invoked from MyApp, it needs other jars that are in its own lib folder.
Also, I can't include MyLib.war in MyApp.ear as the war library is used by several other application deployed to the same managed server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Anyways, thank you for the help! girionis