[jboss-dev-forums] [JBoss AS7 Development] - multiple entitymanager, entity mix-up.

gwa do-not-reply at jboss.com
Wed Oct 26 03:55:48 EDT 2011


gwa [http://community.jboss.org/people/gwa] created the discussion

"multiple entitymanager, entity mix-up."

To view the discussion, visit: http://community.jboss.org/message/633610#633610

--------------------------------------------------------------
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 at 653838e4
        excludeUnlistedClasses: false
        JTA datasource: null
        Non JTA datasource: org.jboss.jca.adapters.jdbc.WrapperDataSource at 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 at 2aa20aac
        excludeUnlistedClasses: false
        JTA datasource: null
        Non JTA datasource: org.jboss.jca.adapters.jdbc.WrapperDataSource at 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
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/633610#633610]

Start a new discussion in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20111026/96abb3d2/attachment.html 


More information about the jboss-dev-forums mailing list