Here is the simplified version of the problem:
SomeClass c = (SomeClass) obj.getSomeClassParent()
not always but it happens sometimes to t
I think it can happen if
SomeClass instance was loaded from ClassLoader X (so its class is SomeClass of CL X or let's call it: CL(X).SomeClass) SomeClass is actually CL(Y).SomeClassSo you have:
CL(X).SomeClassCL(Y).SomeClassOr in other words - not the same class - thus the class cast exception.
Possible duplicate of: ClassCastException when casting to the same class - it has some good suggestions as well.