1 Reply Latest reply on Sep 8, 2016 11:32 AM by anu8802

    EntityManager inject in an EJB 2.1 Sesssion Bean

    naguilar

      I have an application that uses EJB 2.1 stateless sessions beans and JDBC. I would like to move the JDBC towards EJB 3 Entities so I won't have to manage the SQL, but because of time I cannot upgrade my sessions beans (so they must continue to follow the EJB 2.1 spec).

      I've successuflly written and tested the Entities using annotations and have it working properly outside of the container. But when I try to run them 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.

      Please note that in order to make sure that my environment was setup correctly, I created a simple HelloWorld bean and entity using EJB 3 feautes and the dependency injection of my EntityManager works as expected.

      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.5.0_16
      JBoss 4.2.3

      Thanks in advance.