2 Replies Latest reply on Jun 16, 2006 2:32 AM by ben.wang

    ClassCastException of entity after SFSB activate

      I'm using JBoss 4.0.4 GA an I wrote a stateful session bean which has to entitymanager injected (like the following)

      @PersistenceContext(unitName="myunit",type=PersistenceContextType.EXTENDED) protected EntityManager em;


      When the bean is activeted after passivation, I get an ClassCastEx. The following code throws the exception:

      MyEntity m = null;
      Object test = this.em.find(MyEntity.class, aCorrectPkWichIsALong);
      //test is found - debugger says: Yep, it is a ....MyEntity
      m = (MyEntity)o; //ClassCastException
      


      I tried to make the em transient and set him to null - both did not work.

      I also set up a jboss-app.xml in my EAR to separate classloaders:
      <jboss-app>
       <loader-repository>
       dot.com:loader=testproject-Hanse1.ear
       </loader-repository>
      </jboss-app>
      

      but that has no effect, too.

      What could I do?

      Best regards,
      Carsten