Groovy 2.0.1,GroovyCastException在我自己的类? [英] Groovy 2.0.1, GroovyCastException on my own class?
问题描述
我在我的web应用程序项目中广泛使用groovy类。我可以创建一个类型的实例(定义为一个groovy类),但不能在以后回退( GroovyCastException
发生)。
I'm extensively using groovy classes in my web app project. I can create an instance of a type (defined as a groovy class) but can never at a later time cast back to it (GroovyCastException
occurs).
org.codehaus.groovy.runtime.typehandling.GroovyCastException:无法投射对象'com.company.role.delegation.ProfileModel@49ee6848'将类'com.company.role.delegation.ProfileModel'改为'com.company.role.delegation.ProfileModel'类
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.company.role.delegation.ProfileModel@49ee6848' with class 'com.company.role.delegation.ProfileModel' to class 'com.company.role.delegation.ProfileModel'
根据到上述错误消息,源和目标类的类型是相同的。咦?
According to the above error message, the source and destination class types are the same. Huh?
推荐答案
最有可能的原因是该类已经通过不同的类加载器加载了两次。检查两个实例的getClass()。getClassLoader()是否相同。
Most likely the reason is that the class have been loaded twice via different classloaders. Check if the getClass().getClassLoader() for both the instances are identical.
这篇关于Groovy 2.0.1,GroovyCastException在我自己的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!