-
1. Re: EAR Scoped PersistenceUnit
mzeijen Aug 27, 2007 4:14 AM (in response to mzeijen)Hmm, I forgot to put code around the packaging example. Here is it again:
- app.ear - /lib - pu.jar - /META-INF/persistence.xml - aEJB3Lib.jar - DAOEJB3Lib.jar
-
2. Re: EAR Scoped PersistenceUnit
fhh Aug 27, 2007 6:18 AM (in response to mzeijen)Have you defined your class loader reporitory in jboss-app.xml?
Regards
Felix -
3. Re: EAR Scoped PersistenceUnit
mzeijen Aug 27, 2007 6:58 AM (in response to mzeijen)Yes, I have. Looks like this:
<!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd"> <jboss-app> <loader-repository>jboss.loader:loader=wai-processor</loader-repository> </jboss-app>
-
4. Re: EAR Scoped PersistenceUnit
mzeijen Aug 27, 2007 7:00 AM (in response to mzeijen)Other strange thing that I discovered is that the /lib/pu.jar explicitly needs to be definded in the application.xml file else the persistence-unit won't be initialized. Other dependencies in this directory get found. Is this also a bug?
-
5. Re: EAR Scoped PersistenceUnit
mzeijen Aug 30, 2007 4:00 AM (in response to mzeijen)Nobody got any Idea. Should I just register this as a Bug in Jira?
-
6. Re: EAR Scoped PersistenceUnit
alexg79 Aug 30, 2007 3:42 PM (in response to mzeijen)Other strange thing that I discovered is that the /lib/pu.jar explicitly needs to be definded in the application.xml file else the persistence-unit won't be initialized. Other dependencies in this directory get found. Is this also a bug?
No. If you just put your jar in the /lib directory, it doesn't get processed for deployment purposes. All deployables must be listed in application.xml. -
7. Re: EAR Scoped PersistenceUnit
wolfc Aug 30, 2007 5:26 PM (in response to mzeijen)"mzeijen" wrote:
Other strange thing that I discovered is that the /lib/pu.jar explicitly needs to be definded in the application.xml file else the persistence-unit won't be initialized. Other dependencies in this directory get found. Is this also a bug?
In AS 4.2 anything found in lib is added as a library module (added to the classpath) nothing more. If it represents another type of module it must be added to application.xml. -
8. Re: EAR Scoped PersistenceUnit
mzeijen Aug 31, 2007 4:27 AM (in response to mzeijen)I discovered that in AS 4.2 with a JEE5 application.xml file all normal jars in the Lib process are added to the classpath but the file containing the persistence.xml needs to be added to the application.xml as a java module.
I also found a workaround for my Global persistence unit. By using some life cycle interceptor and a custom annotation I inject the persistence context from the JNDI into the persistence manager field. The injector finds the JNDI path of the persistence context via a configuration file that I put on the classpath in lib aEJB3Lib.jar. This way i can reuse my DAOEJB3Lib.jar and on runtime tell it which persistence unit to use.
But I still think that it is a bug that persistence units become global. What do you think? -
9. Re: EAR Scoped PersistenceUnit
superdev Dec 10, 2008 7:52 AM (in response to mzeijen)I tested JBoss GA 5 and find that it is not the case in this release. Persistence.xml should NOT be added to the application.xml as a java module, otherwise, there will be errors saying something like "Context already exists with path 'lib/**.jar".
-
10. Re: EAR Scoped PersistenceUnit
jaikiran Dec 10, 2008 8:35 AM (in response to mzeijen)That's right. The application.xml should not contain the persistence.xml module. Instead you should place the persistence.xml in the META-INF of the jar. See this for a detailed explanation http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/entityconfig.html
-
11. Re: EAR Scoped PersistenceUnit
alrubinger Dec 10, 2008 12:10 PM (in response to mzeijen)EJB 3.0 Persistence Specification, Section 6.2 wrote:
A persistence unit is defined by a persistence.xml file. The jar file or directory whose META-INF
directory contains the persistence.xml file is termed the root of the persistence unit. In Java EE, the root of a persistence unit may be one of the following:
* an EJB-JAR file
* the WEB-INF/classes directory of a WAR file[40]
* a jar file in the WEB-INF/lib directory of a WAR file
* a jar file in the root of the EAR
* a jar file in the EAR library directory
* an application client jar file
S,
ALR