We have a web-application, instance of which get deployed multiple times under the same tomcat (v6.0.14) instance. Suppose the war file is named "app.war", then we deploy "app1.war", "app2.war" and so on.
All the application instances (~20) get deployed correctly. When the servlets on these applications are accessed, sometimes they fail with NoClassDefFoundError
caused by ClassNotFoundException
in tomcat's WebAppClassLoader
. Following is one example -
java.lang.NoClassDefFoundError: com/xxx/APISocketServer$ClientRequestHandler
at com.xxx.APISocketServer$APISocketServerThread.run(APISocketServer.java:143)
Caused by: java.lang.ClassNotFoundException: com.xxx.APISocketServer$ClientRequestHandler
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
... 1 more
The offending classes are part of application code and are not part of any library.
As some of the application instances run correctly, this cannot be a case of classpath mis-configuration. One thing to note is that there are only a couple of classes that fail to load. The classes do not have any static initializer blocks, which could cause failure of class initialization. I have checked tomcat logs (catalina.out, localhost.log) and have not found any class initialization errors.
How should I proceed to debug this problem?