0 Replies Latest reply on Sep 8, 2016 1:24 PM by anu8802

    Entity Manager Null when using EJB 2.1 Session Beans to use EJB 3.0 Entity Beans

    anu8802

      EntityManager inject in an EJB 2.1 Sesssion Bean

      I have an application that uses EJB 2.1 stateless sessions beans and EJB 2.1 Entity Beans. I would like to upgrade to EJB 3.0 Entity Beans. but because of time I cannot upgrade my sessions beans (so they must continue to follow the EJB 2.1 spec).

       

      When I try to run within the container and have JBoss use dependency injection to set the EntityManager on my Session bean, it never works. Basically, the EntityManager is never set and is left as null. If on the Other hand, i create an EntityManagerFactory and create an entityManager from there, that seems to work, but My guess is Application should handle the creating of EntityManagerFactory so us creating it is not safe right.

       

      Therefore, Is it possible to use dependency injection on an EJB 2.1 session bean or must everything be upgraded to EJB 3? Can I mix EJB 2.1 and EJB 3.0 features?

       

      Here is my environment information:
      JDK 1.6
      JBoss 4.2.3

       

      Thanks in advance.