Reputation:
I have a WAR file deployed on a managed server in WebLogic 12c. All the needed 3rd party JARs are put in WEB-INF/lib. By the way, the same WAR works fine in WebSphere and Tomcat. When I run the app, it reports that some class cannot be found, which is in a jar file under WEB-INF/lib.
This class is definitely not shadowed by classes installed with WebLogic. So my first question is why the class is not loaded even if the JAR file in under WEB-INF/lib.
Then I thought maybe I can put the JARs into the system classpath under $DOMAIN_DIR/lib, but the same error occurs. I tried to use the classloader analysis tool to locate the class, it shows the class can be found under in the jar file under $DOMAIN_DIR/lib. Then I am confused why the ClassNotFoundException is thrown then.
I have to admit this is the first time I use WebLogic as the app server based on client's request. So I am not an expert on this. It is highly appreciated if anyone can help me on this issue.
Upvotes: 3
Views: 6145
Reputation: 663
If prefer-web-inf-classes tag in your weblogic.xml file doesn't work, you might be the victim of the following scenario.
Jar files can be placed in multiple locations for Weblogic Ear file.
If you have multiple modules that is referring a common library (Ex: log4j2), then we can use the root lib (/lib) in the ear package, else the library can be packaged with module specific war / ear
In some cases the module specific libraries use the same jar (or) refers the same jar from the common library i.e /lib folder which throws classnotfound as the classloaders for both the lib folders are different.
So the reference between Module specific library and common library is also one of the major cause for this issue.
Upvotes: 0
Reputation: 3203
One good practice to identify which jar file is being loaded is using JVM property: -verbose:class
If finally it is being loaded from your jar file, then probably could be a tree classloading issue.
Upvotes: 0
Reputation: 1119
Use the prefer-web-inf-classes tag in your weblogic.xml file to make sure that WebLogic isn't overriding the jars from somewhere else on the classpath.
For more details, see this page:
https://docs.oracle.com/cd/E24329_01/web.1211/e21049/weblogic_xml.htm#WBAPP600
Upvotes: 1