Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-9155

jboss processes only one persistence.xml file per war file

XMLWordPrintable

      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:

      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>}}
      

      Jboss will only starts the pu1 persistence unit.

      And if the war file has the following structure:

      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>
      

      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:

      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.

      [...]

      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.

      And from section 7:

      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.

              ajustin@redhat.com Ales Justin
              vincent_aumont_jira Vincent A (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: