ClassCastException is thrown when an application tries to cast an object to a class that it is not an instance of. This can occur when the JVM loads a class file, and the class file is not a subclass of the class to which the application is trying to cast the object.
See how to avoid a ClassCastException