ClassCastException when casting to the same class

前端 未结 11 830
小蘑菇
小蘑菇 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 07:37

    I had the same issue while using several JBoss instances on different machines. To bad I didn't stumble across this post earlier.
    There were artifacts deployed on different machines, two of them declared class loaders with identical name.I changed one of the classloader names and everything worked fine => Beware of Copy&Paste!

    Why doesn't the ClassCastException thrown mention the involved class loaders? - I think that would be very useful information.
    Does anyone know if there will be anything like this available in the future? Needing to check the class loaders of 20-30 Artifacts is not that pleasant. Or is there something I missed in the exception text?

    EDIT: I edited the META-INF/jboss-app.xml file and changed the name of the loader, the idea is to have a unique name. At work we use the artifact id(unique) combined with the version inserted by maven({$version}) during the build.
    Using dynamic fields is only optional but helps if you want to deploy different versions of the same application.

    
        
       com.example:archive=unique-archive-name-{$version}
        
    
    

    You can find some info here: https://community.jboss.org/wiki/ClassLoadingConfiguration

提交回复
热议问题