0 Replies Latest reply on Oct 26, 2011 3:55 AM by gwa

    multiple entitymanager, entity mix-up.

    gwa

      Hello,

       

      I'm evaluating JBoss 7 on some project, but I'm facing an issue :

       

      I'm using Spring to initialize my entityManager (JPA provider : Hibernate):

       

      <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
              <property name="persistenceXmlLocations">
                  <list>
                       <value>classpath*:META-INF/persist.xml</value>
                   </list>
              </property>
              ...
      </bean>
      

       

      The persist.xml file are in jar file in WEB-INF/lib  (there are several jar with persistence unit and for instance, user.jar defines the user-pu, order.jar defines the order-pu, ...).

      My entities are listed in orm.xml file. for each persist.xml file, there is one orm.xml file in the same location.

       

      Now, here the full log on hibernate :

       

      DEBUG: org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [
              name: user-pu
              persistence provider classname: org.hibernate.ejb.HibernatePersistence
              classloader: ModuleClassLoader for Module "deployment.my-ear-1.32.0.ear.my.war:main" from Service Module Loader
              Temporary classloader: org.springframework.instrument.classloading.SimpleThrowawayClassLoader@653838e4
              excludeUnlistedClasses: false
              JTA datasource: null
              Non JTA datasource: org.jboss.jca.adapters.jdbc.WrapperDataSource@5626b468
              Transaction type: RESOURCE_LOCAL
              PU root URL: vfs:/content/my-ear-1.32.0.ear/my.war/WEB-INF/lib/user-1.32.0.jar/
              Shared Cache Mode: UNSPECIFIED
              Validation Mode: AUTO
              Jar files URLs []
              Managed classes names [
                      my.package.user.UserEntity1  <-- defined in user.jar 
                      my.package.user.UserEntity2  <-- defined in user.jar
                      ...
                      my.package.order.OrderEntity1 <-- defined in order.jar
                      ...
      

       

      The user-pu manage entities from user jar but also SOME (not all) other entities from other jar...

       

      The other persistence unit define no entity :

      DEBUG: org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [
              name: order-pu
              persistence provider classname: org.hibernate.ejb.HibernatePersistence
              classloader: ModuleClassLoader for Module "deployment.my-ear-1.32.0.ear.my.war:main" from Service Module Loader
              Temporary classloader: org.springframework.instrument.classloading.SimpleThrowawayClassLoader@2aa20aac
              excludeUnlistedClasses: false
              JTA datasource: null
              Non JTA datasource: org.jboss.jca.adapters.jdbc.WrapperDataSource@5626b468
              Transaction type: RESOURCE_LOCAL
              PU root URL: vfs:/content/my-ear-1.32.0.ear/my.war/WEB-INF/lib/order-1.6.jar/
              Shared Cache Mode: UNSPECIFIED
              Validation Mode: AUTO
              Jar files URLs []
              Managed classes names []
              Mapping files names []
              Properties []
      

       

      So "Unknown entity" error pop on every entityManager but the one associated with user-pu. (the first pu).

       

      Is someone have already faced such issue?

      Is there a magic properties into JBoss to fix that?

       

      Thank you