1 Reply Latest reply on Apr 12, 2006 10:01 AM by gvl

    Entity Manager is null in session bean (jboss 4.0.4 CR2)

    gvl

      I am trying to use jboss 4.0.4CR2 with the ejb3 option but at the moment
      when I try to use an EntityManager from within my session bean the entity
      manager is always null.

      I have a stateless session bean where I load the entity manager:

      @Stateless
      public class CategorySessionBean implements CategoryView {
       @PersistenceContext(unitName = "inventPU")
       protected EntityManager manager;
      
      ...
       public load(){
       //HERE THE manager is NULL
       Query q = manager.createQuery("FROM Category");
       }
      ...
      }
      


      I am deploying the application in an ear with the following structure:
      invent.ear
      ...|-META-INF
      ...|-META-INF|-application.xml
      ...|-invent.par
      ...|-invent.war
      


      application.xml:
      <application>
      <display-name>invent</display-name>
      <module>
      <web>
      <web-uri>invent.war</web-uri>
      <context-root>/invent</context-root>
      </web>
      </module>
      <module>
      <ejb>invent.par</ejb>
      </module>
      </application>
      


      invent.par:
      ...|-META-INF
      ...|-META-INF|-persistence.xml
      ...|-gr (the entity and session beans)
      


      persistence.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence>
      <persistence-unit name="inventPU">
      <description> AEGEK invent pesrsistent unit</description>
      <jta-data-source>java:/inventDS</jta-data-source>
      <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
      <property name="hibernate.hbm2ddl.auto" value="create"/>
      </properties>
      </persistence-unit>
      </persistence>
      


      invent.war:
      (jsp and other web related stuff)


      HELP!
      Thanx ...