7 Replies Latest reply on Jan 2, 2007 11:33 AM by Alex Grönholm

    ClassCastException when casting to remote interface

    novad protikin Newbie


      I use JBoss 4.0.5 GA with EJB 3 with Eclipse.
      I have an EJB- project and a Web-project. They are (for now) running in the same VM in JBoss.

      When I get my SessionBean - stub in my web app (via Naming service) and try to cast it to the remote interface, I get a ClassCastException.
      I already found out that the problem lies in the fact that 2 remote interface class files are deployed. It's described in the wiki

      The wiki presents 3 solutions:
      1. remove the duplicate interface from one of the deployed libs.
      I found out that this works in principle.
      My problem with this is, that I don't use an Ant build file where I could simply exclude the file. I use Eclipse to generate the EAR / WAR archive (with Export to... ). Removing the remote interface from the web-archive afterwards solves the problem with the ClassCastException, but is much too time-consuming .

      2. run your application in different VMs -> not a good solution for me right now

      3. enable CallByValue for JNDI
      unfortunately this is not elaborated in the Wiki. From other resources, I found out that some changes to config files should be made, but the descriptions did not fit to JBoss 4.0.5 (obviously the conf-files have been reorganized). I tried to implement the changes all the same but it did not work!
      Next I remembered that during the Jboss install there was an option to "Enable deployment isolation" which sounded like it could solve the problem. So I reinstalled JBoss with this option activated. Unfortunately this did not solve the problem neither.

      One more strang fact: the ClassCastException only occurs if the EJB is a stateful SessionBean. With a stateless SessionBean I have no problem.

      I have already spent way too much time with this problem, so I would be very grateful if s.o. could help me with this.