0 Replies Latest reply on Feb 4, 2010 7:54 PM by Luigi Bitonti

    2 Seam Apps in JBoss 4.3 problem with EntityManagerFactory overwritten

    Luigi Bitonti Newbie

      Hi,


      I am deploying 2 Seam (2.1.2) applications as EARs on JBoss 4.3 with no class-loading isolation (jboss-app.xml is empty). I have 2 different names for the EntityManagerFactory registered in JNDI. This 2 names are defined in the 2 persistence.xml files. 


      Application 1 persistence.xml:


      <property name="jboss.entity.manager.factory.jndi.name" value="java:/app1EntityManagerFactory"/>


      Application 2 persistence.xml:


      <property name="jboss.entity.manager.factory.jndi.name" value="java:/app2EntityManagerFactory"/>



      They are then used in the 2 components.xml files, using the following definitions:


      Application 1 components.xml:


      <persistence:managed-persistence-context name="app1EntityManager"
                                           auto-create="true"
                            persistence-unit-jndi-name="java:/app1EntityManagerFactory" />



      Application 2 components.xml:


      <persistence:managed-persistence-context name="app2EntityManager"
                                           auto-create="true"
                            persistence-unit-jndi-name="java:/app2EntityManagerFactory" />



      My problem is that at container startup the entity manager factory (and the entity manager) for the application that gets loaded last overwrite the first one even if the names are different. Obviously the first application fails at the first request, since the entity manager cannot be found.


      I forgot to say that I inject the entity manager using


      @In(create=true, value="app1EntityManager")
      EntityManager entityManager;



      Does anyone have any idea on how to solve this problem? I have searched the forums and Google for quite some time and tried different (many) things, but none of them seems to work. Thanks.



      Best Wishes


      Luigi