[jboss-user] [EJB 3.0] - EAR Scoped PersistenceUnit
mzeijen
do-not-reply at jboss.com
Mon Aug 27 04:12:50 EDT 2007
Let's say that I create the following package:
- app.ear
- /lib
- pu.jar
- /META-INF/persistence.xml
- aEJB3Lib.jar
- DAOEJB3Lib.jar
The persistence unit defined in the persistence.xml of /lib/pu.jar should be EAR scoped and not Globally Scoped (using a ear scoped classloader). Am I right? At least I understood this from the documentation. The problem is that in JBoss 4.2.1 it looks like that the persistence unit becomes globally. I will explain what the effects are.
As you can see I have this DAOEJB3Lib.jar. It contains the entity classes but also some DAO Stateless beans. Those DAO's get there persistence manager using the unit name defined in the persistence.xml of /lib/pu.jar (lets say it is called pu1). I used this construction so that I can reuse those DAO's for different applications. Because the persistence unit name is hard coded in the DAO's of the DAOEJB3Lib.jar lib we need to define the same name in the persistence.xml. This means that if the DAOEJB3Lib.jar is reused by multiple applications on the same server there will also exist multiple persistence units with the same. If the persistence unit is ear scoped then this setup wouldn't create any problems. Practically however this doesn't work.
All works fine if one application with this DAOEJB3Lib.jar lib is deployed on the server. The problems begin when I deploy a second application that contains the same DAOEJB3Lib.jar. The first application won't work any more because it now retrieves the persistence unit from the second application...
Did I understand the Documents wrong or is there a Bug in the EJB3.0 lib of JBoss 4.2.1?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078238#4078238
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078238
More information about the jboss-user
mailing list