A note on NoClassDefFoundError

E

Esmond Pitt

This seems to cause a lot of confusion. It is caused by several
conditions of which the most common is:

1. As defined for
http://java.sun.com/j2se/1.5.0/docs...[], int, int, java.security.ProtectionDomain)

'NoClassDefFoundError - If name is not equal to the binary name of the
class specified by b ', where 'binary name' is a link to
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ClassLoader.html#name

This in turn is usually because a .class file with the expected filename
was found according to the normal classpath search rules, but it didn't
contain the expected class, either because the file got renamed after
compilation or its position in the directory hierarchy reached from the
classpath doesn't correspond to its declared package name.

2. It can also occur if a directly-referenced class that does exist
(e.g. new A(), needs to load another class that can't be found. In other
words a class that was present when A was compiled isn't present when A
is used, even though A is there. (If A itself isn't there you get
ClassNotFoundException.)

3. It can also be caused by running out of fd's or memory during class
loading.

4. There are also some places in the JDK that turn
ClassNotFoundException into NoClassDefFoundError, presumably because it
is an Error. This is done for some JDK implementation classes, or if
e.g. the RMIClassLoader class defined by
java.rmi.server.RMIClassLoaderSpi doesn't exist.

There may be other causes ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,058
Members
48,769
Latest member
Clifft

Latest Threads

Top