ClassCastException when casting to the same class

前端 未结 11 944
小蘑菇
小蘑菇 2020-11-22 07:09

I have 2 different Java projects, one has 2 classes: dynamicbeans.DynamicBean2 and dynamic.Validator.

On the other project, I load both of

11条回答
  •  一整个雨季
    2020-11-22 08:01

    The class objects were loaded in different classloaders, therefore the instances created from in each of classes are seen as 'incompatible'. This is a common issue in a an environment where there are many different classloaders being used and objects are being passed around. These issues can easily arise in Java EE and portal environments.

    Casting an instance of a class requires that the Class linked to the object being casted is the same as the one loaded by the current thread context classloader.

提交回复
热议问题