2 Replies Latest reply on Sep 15, 2011 10:03 PM by martian

    merging persistence units

    martian

      I'm trying to deploy a WAR that contains multiple persistence unit jar files that are merged into one using Spring's MergingPersistenceUnitManager. For this, I ended up having to name all the persistence units to the same name.

       

      It deploys fine in Tomcat but fails with the "Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit." exception in JBoss 7.0.1 Web Profile. Tried it on 5.1.0.GA and got a similar exception.

       

      The persistence units are bootstrapped by Spring configuration. Is there an easy way to disable JBoss from automatically loading the JAR files as persistence units? Or is there a JBoss/JEE way of merging multiple jars into a single persistence unit?

       

      Any feedback/suggestions are greatly appreciated. Thanks

        • 1. Re: merging persistence units
          smarlow

          Have you tried updating as7/standalone/configuration/standalone.xml to remove the jpa subsystem?  Look for the following lines:

           

          <subsystem xmlns="urn:jboss:domain:jpa:1.0">

              <jpa default-datasource=""/>

          </subsystem>

           

          I don't like this solution as applications that use EE container managed JPA will not work but it might be something for you to try.

          1 of 1 people found this helpful
          • 2. Re: merging persistence units
            martian

            Thanks for the response Scott... I started going in the direction you suggested and made some progress. But I agree that changing the application server configuration to address this didn't sound good.

             

            In the end, I changed the "persistence.xml" to "spring-persistence.xml" and configured the "MergingPersistenceUnitManager" to look for META-INF/spring-persistence.xml (instead of META-INF/persistence.xml) through the "persistenceXmlLocations" property. Since JBoss looks for META-INF/persistence.xml, it didn't load it.