0 Replies Latest reply on May 12, 2009 3:41 PM by arshadm

    Seam 2.1.1GA and Glassfisn V2.1 EntityManager woes

    arshadm
      Hi,

      I have an application which is behaving rather weirdly on Glassfish v2.1. The application is packaged as an EAR with the following directory structure:-

      EAR -
          ejb1.jar
          ejb2.jar
          app.war
          lib/
             pu.jar
             entities1.jar
             entities2.jar

      The components.xml contains the following for seam managed persistence:-

      <!-- managed persistence context -->     
          <persistence:managed-persistence-context name="entityManager"
               persistence-unit-jndi-name="java:comp/env/app1EMF" auto-create="true"/>

      The web.xml contains

          <!--  persistence unit -->
          <persistence-unit-ref>
             <persistence-unit-ref-name>app1EMF</persistence-unit-ref-name>
             <persistence-unit-name>app1PU</persistence-unit-name>
          </persistence-unit-ref>

      I have an EJB stateful session bean say Bean1 that uses @In EntityManager entityManager, to get access to the entity manager.

      Now if I access the page /test.seam which contains an el element like #{Bean1.property} this works fine. But now if I put a link on that page to say "/test2.seam" with a page parameter which get's set on the EJB bean1 then I get the following exception.

      Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/app1EMF
              at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:834)
              at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
              at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:396)
              at javax.naming.InitialContext.lookup(InitialContext.java:392)
              at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:241)

      This is really weird, because the system was obviously able to lookup the entity manager the first time (because when /test.seam was rendered the bean properties were displayed) but on the click of the link the second time it is saying that no object is bound to the entity manager factory.

      Does anyone have a clue what is going on. It's driving me mad!!!

      Regards.