Why am I getting a NoClassDefFoundError in Java?

Submitted 3 years, 6 months ago
Ticket #252
Views 250
Language/Framework Java
Priority Low
Status Closed

I am getting a NoClassDefFoundError when I run my Java application. What is typically the cause of this?

Submitted on Oct 19, 20
add a comment

1 Answer

Verified

This exception indicates that the JVM looked in its internal class definition data structure for the definition of a class and did not find it. This is different than saying that it could not be loaded from the classpath. Usually this indicates that we previously attempted to load a class from the classpath, but it failed for some reason - now we're trying to use the class again (and thus need to load it, since it failed last time), but we're not even going to try to load it, because we failed loading it earlier (and reasonably suspect that we would fail again). The earlier failure could be a ClassNotFoundException or an ExceptionInInitializerError (indicating a failure in the static initialization block) or any number of other problems. The point is, a NoClassDefFoundError is not necessarily a classpath problem.

Submitted 3 years, 6 months ago


Latest Blogs