Java Quiz: What Does NoClassDefFoundError mean?
It took me a while to figure this out: NoClassDefFoundError is not the same as ClassNotFoundException.
Published at DZone with permission of Axel Rauschmayer, author and DZone MVB.- ClassNotFoundException: The given class could not be found.
- NoClassDefFoundError: The given class could be found, but something went wrong when initializing it (an interface it implemented could not be found, something went wrong in a static initializer etc.).
This article has more information.
From http://2ality.blogspot.com/2010/11/java-quiz-what-does-noclassdeffounderro.html
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)
Tags:






Comments
Chris Treber replied on Thu, 2010/11/18 - 6:24am
Cosmin Mutu replied on Thu, 2010/11/18 - 7:48am
I don`t wanna be a bitch, but it was here all along (I think it`s pretty clear) : http://download.oracle.com/javase/1.4.2/docs/api/java/lang/NoClassDefFoundError.html
Cheers.
Robert Saulnier replied on Thu, 2010/11/18 - 8:17am
C:\>java -showversion NonExistingClass
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
Exception in thread "main" java.lang.NoClassDefFoundError: NonExistingClass
Caused by: java.lang.ClassNotFoundException: NonExistingClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: NonExistingClass. Program will exit.
Bruce Wallace replied on Thu, 2010/11/18 - 11:49am
This is very useful! I recently restarted a legacy J2EE server and a web app suddenly started failing as per below. I have been scratching my head as to how some class file got deleted that was there before. This tells me I've been barking up the wrong tree! THANKS!
500 Internal Server Error