9 Replies Latest reply on Feb 17, 2006 9:50 AM by rorschach

    Unable to lookup EntityManager in 4.0.3 SP1 with EJB3 RC4-PF

    donniedarko

      Im trying to convert our RC3 apps to RC4-PFD but I cannot get EntityManager lookup through JNDI to work. Similar posts have already been posted , but I have read them and none have concluded with an answer to this.

      The following persistence.xml registers my entitymanager in JNDI just fine.

      <persistence>
       <persistence-unit name="test">
       <jta-data-source>java:testDS</jta-data-source>
       <properties>
       <property name="jboss.entity.manager.jndi.name" value="java:/EntityManagers/testEM"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagers/testEMFactory"/>
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       <property name="hibernate.show_sql" value="false" />
       </properties>
       </persistence-unit>
      </persistence>
      


      So far so good and I can see in the JNDI view service in JMX-Console that it is registred correct
      java: Namespace
      EntityManagers (class: org.jnp.interfaces.NamingContext)
       | +- testEMFactory (class: org.jboss.ejb3.entity.InjectedEntityManagerFactory)
       | +- testEM (class: org.jboss.ejb3.entity.InjectedEntityManager)
      

      , but when i try to look it up it just returns null....

      EntityManager em = (EntityManager)ctx.lookup("java:/EntityManagers/testEM");
      


      No exception...nothing..the "em" variable just gets set to null.

      Best regards