1 Reply Latest reply on Apr 25, 2015 1:40 PM by Wolf-Dieter Fink

    EJB Lookup causing ClassCastException JBoss EAP 6.2

    Siva Masilamani Newbie




      We have two EAR applications and we are trying to look up an EJB resides on EAR1 from EAR2 application and getting ClassCastException for one of the classes in EJB1.jar
















      One of the classes from EJB2.jar is trying to look up an EJB from EJB1.jar and I can see that EJB look up is working fine but when we call one of the methods on EJB1 ,we are getting ClassCastException for one of the utility classes (BranchSummarry.java)



      This is what I have tried with no luck:

      1. Created a module for EAR1.EJB1.jar inside module folder and added it as a dependancy in Jboss-deployment-structure.xml on EAR2 but again same error.

      2.Added the EJB1.jar to the lib dir of EAR2 directly and again getting same error




      Another interesting thing in jboss-deployment-structure.xml of EAR2, is that unless I add export =true,I am getting ClassNotFoundException for  BranchSummary.java from EJB2 module,I do not understand why export=true works but adding it throws ClassCastException.



      As a last try,I enabled jvm verbose to see classes loaded and see which classloader is loading that class and found that only two loader do that,one loaded from EAR1.ear and another is from module that I created and if I put that  jar inside EAR2 again I see one loaded as part of EAR1 and another loaded as part of EAR2.



      Your help is much appreciated.