Good morning. After generating an AAR file from the WSDL and deploying, I am getting a NoClassDefFoundError on the skeleton interface when a client call comes in.
What’s strange is that my Message Receiver, in the same location of the AAR file, is cited in the stack trace since I’ve defined it in services.xml. It’s unclear why it would be able to load one class, but not another in the exact same path.
My service class implements CoreSkeletonInteface and is defined in services.xml, however it exists outside the AAR file, in the webapp’s WEB-INF/classes folder. I’m assuming that will not cause any issues.
Here’s the stack trace. Any help would be appreciated.
java.lang.NoClassDefFoundError: org/caqh/www/soap/wsdl/CoreSkeletonInterface
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.apache.axis2.util.Loader.loadClass(Loader.java:261)
at org.apache.axis2.util.Loader.loadClass(Loader.java:229)
at org.apache.axis2.receivers.AbstractMessageReceiver.makeNewServiceObject(AbstractMessageReceiver.java:250)
at org.apache.axis2.receivers.AbstractMessageReceiver.getTheImplementationObject(AbstractMessageReceiver.java:297)
at org.caqh.www.soap.wsdl.CoreMessageReceiverInOut.invokeBusinessLogic(CoreMessageReceiverInOut.java:23)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
You say that your generated class files were inside the AAR, but your service class was stored outside it? in that case, the service class wouldn’t have access to the generated class files, due to the way that class loaders work.
There are basically three class loaders here:
The Axis2 class loader can read inside the AAR and access classes stored there. Its parent class loader is the catalina class loader.
The catalina class loader is provided by the web application environment. It can read the files that come with the environment. Its parent is the Java class loader.
The Java class loader is the standard class loader which uses CLASSPATH, jars installed with the JRE, etc.
Each class loader can defer to its parent. So, for example, if the Axis2 class loader has to resolve a reference to java.lang.String, it will defer to the catalina loader, which defers to the java loader, which loads the class from the JRE environment.
However, the reverse won’t work, and that caused your error. Axis2 referenced your service class, resulting in a call to the Axis2 loader to load the class. The Axis2 loader deferred to the Catalina loader, which found and attempted to load the class. Your service class references the skeleton interface class, so the catalina class loader had to resolve that reference. However, the catalina loader doesn’t have access to the Axis2 loader, so it couldn’t “see” any classes inside the AAR.