Illarion Kovalchuk
Illarion Kovalchuk

Reputation: 5894

NoClassDefFoundError in a web application under heavy loading

I am performing load tests on my java web app, running in tomcat 7 with NiO connector, running simulation of 1000 users working simultaniously, and I get unexpected result -- application turns to completely unusable state, it gives user error with status 500 and NoClassDefFoundError for different classes of the application, for example MVC controllers and others.

Looks like tomcat "undeploys" it somehow for some reason.

Do you have any thoughts how to fix it and what could be the source of the problem?

Upvotes: 1

Views: 178

Answers (3)

Stephen C
Stephen C

Reputation: 719249

(This is an elaboration on Peter Lawrey's answer)

One of the common causes of NoClassDefFoundError exceptions is attempting to load a class that has previously failed class loading, or that depends on a class that has previously failed class loading.

If this is what is happening, the stack traces for the later NoClassDefFoundError exceptions tend to be uninformative. The real cause of the problem is typically to be found in an earlier log event.


I doubt that Tomcat is automatically undeploying things. If it did, I'd expect different symptoms. (Even if Tomcat undeploys something, the JVM will only unload a class if it is no longer reachable. And any attempt to load some other class that depends on the unloaded class will trigger a new copy to be loaded from the classpath.)

As to the source of the problem, there's a good chance that you've got a problem in your application's static initialization. Have you configured the webapp to do lazy loading of some of the servlets?

Upvotes: 3

kkites
kkites

Reputation: 349

may be it is not able to take the load... did you try reducing the concurrent users? try a different connector ajp vs http? with nio/bio? do the tests involve io operations?

Upvotes: 0

Peter Lawrey
Peter Lawrey

Reputation: 533680

You could be getting this error is the class failed to load earlier. The true error could be more informative.

Upvotes: 1

Related Questions