ClassNotFoundException is a checked exception and subclass of java.lang.Exception. Recall that, checked exceptions need to be handled either by providing try/catch or by throwing it to the caller. You get this exception when JVM is unable to load a class from the classpath. So, troubleshooting this exception requires an understanding of how classes get loaded and the significance of classpath.
Root Cause of java.lang.ClassNotFoundException
Java doc of java.lang.ClassNotFoundException puts it quite clearly. It gets thrown in below cases when the class definition is not found-
- Load class using forname method of class Class
- Load class using findSystemClass method of ClassLoader
- Load using loadClass method of ClassLoader
http://javaeesupportpatterns.blogspot.in/2012/11/javalangclassnotfoundexception-how-to.html
No comments:
Post a Comment