4 Replies Latest reply on Apr 18, 2005 11:16 AM by Chris Richardson

    Accessing the EntityManager from a non-EJB class

    Chris Richardson Newbie

      EJBs can obtain a reference to an EntityManager through dependency injection. But how can a non-EJB class called by an EJB access the EntityManager?

      Is it simply a matter of using JNDI code like this?

      EntityManager em = (EntityManager) new InitialContext()
       .lookup("java:comp.ejb3/env/EntityManager");


      This works in preview 5 but is legal and does it perform well?

      Thanks

      Chris