5 Replies Latest reply on Feb 21, 2006 7:39 AM by epbernard

    4.0.4RC1 / Lazy Fetch / EntityManagerFactory JNDI Lookup

    knifegun

      I am trying to turn Lazy fetch on my EJB 3.0 entity beans. I have a utility class that handles the EntityManager persistence on behalf of a web application. I have packaged my EJB in a JAR file called blackarrow.ejb3. I have packaged the web application in a seperate war file called blackarrow.war. I deployed both the *.ejb3 file and the *.war file seperately. I have the following persistence.xml defined that is bundled with the *.ejb3:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence>
       <persistence-unit name="blackarrow-core" transaction-type="JTA">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/BlackArrowDS</jta-data-source>
       <properties>
       <property name="jboss.entity.manager.jndi.name" value="java:/EntityManagers/blackarrow-core"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagers/blackarrow-core-factory"/>
       </properties>
       </persistence-unit>
      </persistence>


      In the WAR file, I try to lookup the EntityManagerFactory via the following code:


      public static EntityManagerFactory getEntityManagerFactory() {
       EntityManagerFactory factory = null;
       try {
       InitialContext ctx = new InitialContext(CONTEXT_PROPERTIES);
       factory = (EntityManagerFactory)ctx.lookup("EntityManagers/blackarrow-core-factory");
       } catch (Exception ex) { ex.printStackTrace(); }
       return factory;
       }
      }
      


      When I execute the code above in the WAR file, I get the following exception. Does anybody know what I am doing wrong and can point me to a working sample?

      Thanks in advance!

      16:21:37,351 ERROR [STDERR] javax.naming.NameNotFoundException: remote not bound
      16:21:37,351 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      16:21:37,351 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      16:21:37,351 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      16:21:37,351 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
      16:21:37,351 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
      16:21:37,351 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      16:21:37,351 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      16:21:37,351 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      16:21:37,351 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      16:21:37,351 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      16:21:37,351 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:153)
      16:21:37,351 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
      16:21:37,351 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      16:21:37,351 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)