0 Replies Latest reply on Dec 22, 2009 5:34 PM by Timothy Potter

    Yet another EntityManagerFactory not found in JNDI issue (with workaround)

    Timothy Potter Newbie

      I know, this error has been posted too many times! And I'm beyond it, so am just sharing my experience in case someone else hits it ...

      So I have a Seam 2.2.0 EAR (WAR and a few MDBs) application running on JBoss 4.2.3 (all configuration - cluster, Java 6). On Windows, the following configuration (from components.xml) works fine:

      <persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="@puJndiName@"/>

      However, when I moved this over to my Fedora Linux server (running in the Amazon EC2) I would get the following error:

      java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/viyyaEntityManagerFactory
         at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:245)
         at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:78)
         at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:107)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
         at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)

      I'm aware that this error can happen if you have an error in an entity annotation or something, but that's not the case here as evidenced by the app running fine on Windows and that if I change my components.xml to:

      <persistence:entity-manager-factory name="entityManagerFactory" 
        <persistence:managed-persistence-context name="entityManager" 
                                                 auto-create="true" entity-manager-factory="#{entityManagerFactory}" 

      Then it works on my Linux server too. Unfortunately, there isn't much else in the logs (even with Seam log verbosity turned to debug). Has anyone else seen this? Or can shed some light on what might be going on? Not urgent, but I'd really like to know why it works differently in the two environments?