ClassLoader issues are difficult to find and take a long time to debug. They fall into one of two categories:
Not enough visibility
You'll see one of the following exceptions:
ClassNotFoundException
Java API methods such as Class.forName( ) or ClassLoader.loadClass( ) throw a ClassNotFoundException. This exception happens when a class loader tries to load a class and can't find the class. Here are some possible causes:
A JAR or directory for the class is not available, so the ClassLoader asked to load the class, or to its parent(s).
The wrong ClassLoader is used to load the class.
NoClassDefFoundError
A NoClassDefFoundError has the same causes as the ClassNotFoundException, but there is an additional reasona class depends on other classes that are inaccessible from the current ClassLoader. The other classes may reside only in a child or sibling ClassLoader, neither of which is available to the current ClassLoader.
Too much visibility
This happens when you have a duplicate class and the problem manifests as a ClassCastException. For example, you could include the same JAR file (bundled with several libraries) more than once in your deployment.