[jboss-jira] [JBoss JIRA] Commented: (JBAS-9155) jboss processes only one persistence.xml file per war file

Scott Marlow (JIRA) jira-events at lists.jboss.org
Tue Mar 29 10:22:38 EDT 2011


    [ https://issues.jboss.org/browse/JBAS-9155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12592431#comment-12592431 ] 

Scott Marlow commented on JBAS-9155:
------------------------------------

Vincent,

Thank you for reporting this issue.  Would you be interested in helping to write a test case for AS7 that reproduces the above structure?  I can provide guidance for putting it together if your interested.  

If your interested in helping.  I can give you the steps to get the AS7 source and such a test in AS7.  

The test could likely go in a new https://github.com/jbossas/jboss-as/tree/master/testsuite/integration/src/test/java/org/jboss/as/testsuite/integration/jpa/severalPUJars folder.  

Another example test is here https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/src/test/java/org/jboss/as/testsuite/integration/jpa/epcpropagation/EPCPropagationTestCase.java

All of the classes in the epcpropagation/ folder are part of the test.  

Some other examples of how a test case packages up the test classes into archives are here:

https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/src/test/java/org/jboss/as/tests/deployment/classloading/ear/EarClassLoadingTestCase.java

https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/src/test/java/org/jboss/as/tests/deployment/classloading/ear/EarClassPath3TestCase.java

Don't worry so much about the obstacles of getting the source and contributing the test.  

What do you think?

Thanks,
Scott

>  jboss processes only one persistence.xml file per war file
> -----------------------------------------------------------
>
>                 Key: JBAS-9155
>                 URL: https://issues.jboss.org/browse/JBAS-9155
>             Project: JBoss Application Server
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: JPA / Hibernate
>    Affects Versions: 6.0.0.Final
>            Reporter: Vincent A
>            Assignee: Scott Marlow
>              Labels: deployment, jboss, jpa, persistence, war
>
> If a war file contains several Persistence Archive jars, JBoss starts only the persitence unit(s) defined in the first jar it scans, ignoring the remaining ones.
> For instance, given the following war file:
> {code}
> my-war
>   +-- WEB-INF
>      +-- lib
>         +-- pu1.jar
>            +-- META-INF
>               + persistence.xml   // <persistence-unit name="pu1" >...</persistence-unit>
>         +-- pu2.jar
>            +-- META-INF
>               + persistence.xml   // <persistence-unit name="pu2" >...</persistence-unit>}}
> {code}
> Jboss will only starts the pu1 persistence unit.
> And if the war file has the following structure:
> {code}
> my-war
>   +-- WEB-INF
>      +-- classes
>         +-- META-INF
>            + persistence.xml     // <persistence-unit name="pu0" >...</persistence-unit>
>      +-- lib
>         +-- pu1.jar
>            +-- META-INF
>               + persistence.xml   // <persistence-unit name="pu1" >...</persistence-unit>
>         +-- pu2.jar
>            +-- META-INF
>               + persistence.xml   // <persistence-unit name="pu2" >...</persistence-unit>
> {code}
> Jboss starts pu0, and skips the PU's defined in pu1.jar and pu2.jar.
> This behaviour is non-compliant. Section 6.2 of the spec states that:
> {quote}
> A persistence unit may be packaged within one or more jar files 
> contained within a WAR or EAR, as a set of classes within an 
> EJB-JAR file or in the WAR classes directory, or as a combination 
> of these as defined below.
> {quote}
> [...]
> {quote}
> It is not required that an EJB-JAR or WAR containing a persistence
>  unit be packaged in an EAR unless the persistence unit contains 
> persistence classes in addition to those contained in the EJB-JAR 
> or WAR. 
> {quote}
> And from section 7:
> {quote}
> 7.1.1    Responsibilities of the Container
> At deployment time the container is responsible for scanning the 
> locations specified in Section 6.2 and discovering the persistence.xml 
> files and processing them.
> When the container finds a persistence.xml file, it processes the 
> persistence unit definitions that it contains.
> {quote}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list