6 Replies Latest reply on Sep 8, 2005 4:10 PM by dgreen999

    EJB2 interop, how to obtain EntityManager

    triathlon98

      I am currently stuck with having a lot of EJB2 client code and am in the process of migrating my beans to using EJB3 entity beans instead of CMP2.1.

      However, I have a problem. How can I obtain the current EntityManager.

      If I create new instance through the EntityManagerFactory, then I end up having distinct managers. I have tried looking up with

      String enc = org.jboss.ejb3.Container.ENC_CTX_NAME + "/env/" + unit;
      return (EntityManager)ctx.lookup(enc);

      but this finds nothing. As these are EJB2 beans, I cannot inject the ENtityManager (seems no t to work).

      Any clues?

      Thanks,
      Joachim