5 Replies Latest reply on Dec 18, 2015 2:49 PM by smarlow

    Redeploy dependent WAR fails with duplicate resource error for persistence unit

    jasonholmberg

      This is essentially the same described in Redeploy dependent ear fails with duplicate resource error for persistence unit by specifically focusing on web deployments.

       

      This example consists of two simple web apps: App1 and App2.  They both initially deploy cleanly.  In this example App2 depends on App1 with this dependency defined in a jboss-deployment-structure.xml file, list below:

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
          <deployment>
              <dependencies>
                    <module name="deployment.app1.war" />
              </dependencies>
          </deployment>
      </jboss-deployment-structure>
      
      

       

      App2 also has a simple, do-nothing Persistence Unit name MyPU:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence
          version="2.1"
          xmlns="http://xmlns.jcp.org/xml/ns/persistence"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
          <persistence-unit name="MyPU" transaction-type="JTA">
              <properties>
                <!-- nothing here -->
              </properties>
          </persistence-unit>
      </persistence>
      

       

      This is the log output at start up:

      08:14:39,440 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 2) - WFLYDR0001: Content added at location C:\Servers\wildfly-9.0.2.Final\standalone\data\content\82\a283014519aca7a2682f13f1e7765ba306339b\content
      08:14:39,448 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) - WFLYSRV0027: Starting deployment of "app1.war" (runtime-name: "app1.war")
      08:14:39,605 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) - WFLYWELD0003: Processing weld deployment app1.war
      08:14:39,657 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-3) - HV000001: Hibernate Validator 5.1.3.Final
      08:14:39,755 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) - WFLYWELD0006: Starting Services for CDI deployment: app1.war
      08:14:39,789 INFO  [org.jboss.weld.Version] (MSC service thread 1-3) - WELD-000900: 2.2.16 (SP1)
      08:14:39,799 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) - WFLYWELD0009: Starting weld service for deployment app1.war
      08:14:40,431 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 14) - WFLYUT0021: Registered web context: /app1
      08:14:40,619 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) - WFLYSRV0010: Deployed "app1.war" (runtime-name : "app1.war")
      08:14:45,668 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 2) - WFLYDR0001: Content added at location C:\Servers\wildfly-9.0.2.Final\standalone\data\content\56\525fec6e815870ce58cf71a6eafb8515dad271\content
      08:14:45,673 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) - WFLYSRV0027: Starting deployment of "app2.war" (runtime-name: "app2.war")
      08:14:45,726 INFO  [org.jboss.as.jpa] (MSC service thread 1-5) - WFLYJPA0002: Read persistence.xml for MyPU
      08:14:45,755 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 14) - WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'app2.war#MyPU'
      08:14:45,758 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) - WFLYWELD0003: Processing weld deployment app2.war
      08:14:45,797 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 14) - HHH000204: Processing PersistenceUnitInfo [
              name: MyPU
              ...]
      08:14:45,871 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 14) - HHH000412: Hibernate Core {4.3.10.Final}
      08:14:45,873 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 14) - HHH000206: hibernate.properties not found
      08:14:45,875 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 14) - HHH000021: Bytecode provider name : javassist
      08:14:45,904 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) - WFLYWELD0006: Starting Services for CDI deployment: app2.war
      08:14:45,909 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) - WFLYWELD0009: Starting weld service for deployment app2.war
      08:14:45,919 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 14) - WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'app2.war#MyPU'
      08:14:45,982 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 14) - HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
      08:14:46,211 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 14) - HHH000400: Using dialect: org.hibernate.dialect.SQLServer2008Dialect
      08:14:46,244 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 14) - HHH000397: Using ASTQueryTranslatorFactory
      08:14:46,522 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 6) - WFLYUT0021: Registered web context: /app2
      08:14:46,680 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) - WFLYSRV0010: Deployed "app2.war" (runtime-name : "app2.war")
      
      

       

      Things breakdown when you redeploy App1 (the app the App2 has delcared a dependency on), this is the result:

      08:27:33,315 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 1) - WFLYDR0001: Content added at location C:\Servers\wildfly-9.0.2.Final\standalone\data\content\89\cb02842c45df9b8bb05056a2eb2c82809d2dbf\content
      08:27:33,328 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 68) - WFLYUT0022: Unregistered web context: /app2
      08:27:33,329 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 67) - WFLYUT0022: Unregistered web context: /app1
      08:27:33,354 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) - WFLYWELD0010: Stopping weld service for deployment app1.war
      08:27:33,354 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 70) - WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'app2.war#MyPU'
      08:27:33,356 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) - WFLYWELD0010: Stopping weld service for deployment app2.war
      08:27:33,357 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 70) - WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'app2.war#MyPU'
      08:27:33,380 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) - WFLYSRV0028: Stopped deployment app1.war (runtime-name: app1.war) in 59ms
      08:27:33,382 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) - WFLYSRV0027: Starting deployment of "app1.war" (runtime-name: "app1.war")
      08:27:33,420 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) - WFLYSRV0070: Deployment restart detected for deployment app2.war, performing full redeploy instead.
      08:27:33,425 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) - WFLYWELD0003: Processing weld deployment app1.war
      08:27:33,441 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) - WFLYSRV0028: Stopped deployment app2.war (runtime-name: app2.war) in 19ms
      08:27:33,442 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) - WFLYSRV0027: Starting deployment of "app2.war" (runtime-name: "app2.war")
      08:27:33,476 INFO  [org.jboss.as.jpa] (MSC service thread 1-7) - WFLYJPA0002: Read persistence.xml for MyPU
      08:27:33,485 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) - WFLYWELD0006: Starting Services for CDI deployment: app1.war
      08:27:33,488 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) - WFLYWELD0009: Starting weld service for deployment app1.war
      08:27:33,490 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 70) - WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'app2.war#MyPU'
      08:27:33,491 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 70) - HHH000204: Processing PersistenceUnitInfo [
              name: MyPU
              ...]
      08:27:33,494 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) - WFLYWELD0003: Processing weld deployment app2.war
      08:27:33,602 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) - MSC000001: Failed to start service jboss.deployment.unit."app2.war".INSTALL: org.jboss.msc.service.StartException
      in service jboss.deployment.unit."app2.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "app2.war"
              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:163) [wildfly-server-1.0.2.Final.jar:1.0.2.Final]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.6.Final.jar:1.2.6.Final]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.6.Final.jar:1.2.6.Final]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
              at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
      Caused by: java.lang.IllegalStateException: WFLYCTL0075: Duplicate resource app2.war#MyPU
              at org.jboss.as.controller.registry.AbstractModelResource$DefaultResourceProvider.register(AbstractModelResource.java:248)
              at org.jboss.as.controller.registry.AbstractModelResource.registerChild(AbstractModelResource.java:143)
              at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.addManagementConsole(PersistenceUnitServiceHandler.java:1128)
              at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deployPersistenceUnitPhaseTwo(PersistenceUnitServiceHandler.java:704)
              at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.addPuService(PersistenceUnitServiceHandler.java:289)
              at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.handleWarDeployment(PersistenceUnitServiceHandler.java:200)
              at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deploy(PersistenceUnitServiceHandler.java:131)
              at org.jboss.as.jpa.processor.PersistenceCompleteInstallProcessor.deploy(PersistenceCompleteInstallProcessor.java:55)
              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:156) [wildfly-server-1.0.2.Final.jar:1.0.2.Final]
              ... 5 more
      
      
      08:27:33,657 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 70) - WFLYUT0021: Registered web context: /app1
      08:27:34,009 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) - WFLYSRV0016: Replaced deployment "app1.war" with deployment "app1.war"
      08:27:34,010 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) - WFLYCTL0183: Service status report
      WFLYCTL0184:    New missing/unsatisfied dependencies:
            service jboss.deployment.unit."app2.war".beanmanager (missing) dependents: [service jboss.deployment.unit."app2.war".weld.weldClassIntrospector, service jboss.deployment.unit."app2.war".batch.environment]
      WFLYCTL0186:   Services which failed to start:      service jboss.deployment.unit."app2.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."app2.war".INSTALL:
      WFLYSRV0153: Failed to process phase INSTALL of deployment "app2.war"
      

       

      It looks like WildFly is really trying to deploy the apps, but there is a lot of deployment stopping and starting going on and it seems that the stopping of the persistence unit get lost in there someplace or it gets stopped and then started again and then not stopped again and then when WildFly logs this:

      08:27:33,420 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) - WFLYSRV0070: Deployment restart detected for deployment app2.war, performing full redeploy instead.
      

      It is trying to really deploy app2 and it tries to start the Persistence Unit again and that is when app2 finally fails. Browsing to the applications results in a 404, but in the deployments directory the marker file still reads app2.war.deployed.

       

      Also, I have tested this in WildFly 8.2.0, 8.2.1, 9.0.1, and 9.0.2 all fail in the same way.

       

      Has anyone determined a work-around for this bug that is better than redeploying App2? We have a number of applications that rely on this sort of dependency. It may not be the best configuration, but it is something we have to live with until we have the cycles to change.

       

      The code for the sample applications is here: slowtrailrunner/wildfly-deployment-dependency · GitHub

       

      Thanks,

      Jason

        • 1. Re: Redeploy dependent WAR fails with duplicate resource error for persistence unit
          jasonholmberg

          At smarlow's request, I tried this with the latest WildFly 10 build #2122 and it fails in the same way. Logs attached.

          • 2. Re: Redeploy dependent WAR fails with duplicate resource error for persistence unit
            smarlow

            Thanks Jason,

             

            I think that we also need a way to share the internal JPA PersistenceUnitService dependency as well as the classloader (module) dependencies.  The PersistenceUnitService service is an internal deployment thing that is used to represent the deployed persistence unit.  Currently, EE components within an application deployment, have a service dependency on the JPA persistence unit.  We don't currently have a way to express the service dependency across application deployments.  Not sure if any of this makes sense (its mostly about deployment internals). 

             

            I'm out of time to talk about this more now.

             

            Scott

            • 3. Re: Redeploy dependent WAR fails with duplicate resource error for persistence unit
              jasonholmberg

              Scott,

               

              I think this kind of makes sense, but it is not clear why sharing the PersistenceUnitService will help in the hot deployment process.  It really seems as though the initial PU is not complete stopped or stopped at all before the next one is started.  Is there any kind of possible work-around where I could hook into some kind of EE life-cycle event to make sure the PU is fully stopped, or perhaps check for the PU existence and if it is there kill it before another is started?

               

              Thanks,

              Jason

              • 4. Re: Redeploy dependent WAR fails with duplicate resource error for persistence unit
                jasonholmberg

                I turned logging way up just because I can't leave things alone:

                 

                This is logging from redeploying the dependent WAR.

                 

                11:12:56,537 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 1) WFLYDR0001: Content added at location C:\Servers\wildfly-10.0.0.CR5-SNAPSHOT\standalone\data\content\b1\0dca93eeddb971a11824f06496aae9db1c56ae\content
                11:12:56,552 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 64) WFLYUT0022: Unregistered web context: /app1
                11:12:56,553 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 65) WFLYUT0022: Unregistered web context: /app2
                11:12:56,559 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0010: Stopping weld service for deployment app1.war
                11:12:56,569 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) WFLYWELD0010: Stopping weld service for deployment app2.war
                11:12:56,593 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 67) WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'app2.war#MyPU'
                11:12:56,597 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 67) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'app2.war#MyPU'
                11:12:56,608 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0028: Stopped deployment app1.war (runtime-name: app1.war) in 64ms
                11:12:56,609 DEBUG [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) Entered VERIFY stage; waiting for service container to settle
                11:12:56,609 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "app1.war" (runtime-name: "app1.war")
                11:12:56,634 TRACE [org.jboss.as.jpa] (MSC service thread 1-7) parse checking if "/C:/Servers/wildfly-10.0.0.CR5-SNAPSHOT/bin/content/app1.war/WEB-INF/classes/META-INF/persistence.xml" exists, result = false
                11:12:56,634 TRACE [org.jboss.as.jpa] (MSC service thread 1-7) parsed persistence unit definitions for war app1.war
                11:12:56,634 TRACE [org.jboss.as.jpa] (MSC service thread 1-7) incrementing PU count for app1.war by 0
                11:12:56,635 DEBUG [org.jboss.as.jpa] (MSC service thread 1-7) added javax.persistence.api:main dependency to app1.war
                11:12:56,648 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0070: Deployment restart detected for deployment app2.war, performing full redeploy instead.
                11:12:56,651 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) WFLYWELD0003: Processing weld deployment app1.war
                11:12:56,665 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0028: Stopped deployment app2.war (runtime-name: app2.war) in 16ms
                11:12:56,666 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "app2.war" (runtime-name: "app2.war")
                11:12:56,696 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0006: Starting Services for CDI deployment: app1.war
                11:12:56,702 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0009: Starting weld service for deployment app1.war
                11:12:56,720 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) parse checking if "/C:/Servers/wildfly-10.0.0.CR5-SNAPSHOT/bin/content/app2.war/WEB-INF/classes/META-INF/persistence.xml" exists, result = true
                11:12:56,721 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) parse persistence.xml: attribute value(0) = MyPU
                11:12:56,721 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) parse persistence.xml: attribute value(1) = JTA
                11:12:56,721 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) parse persistence.xml: element=properties
                11:12:56,721 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) parse persistence.xml: reached ending persistence-unit tag
                11:12:56,721 INFO  [org.jboss.as.jpa] (MSC service thread 1-8) WFLYJPA0002: Read persistence.xml for MyPU
                11:12:56,721 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) PersistenceUnitMetadataImpl(version=2.1) [
                        name: MyPU
                        jtaDataSource: null
                        nonJtaDataSource: null
                        transactionType: JTA
                        provider: org.hibernate.jpa.HibernatePersistenceProvider
                        classes[
                        ]
                        packages[
                        ]
                        mappingFiles[
                        ]
                        jarFiles[
                        ]
                        validation-mode: AUTO
                        shared-cache-mode: UNSPECIFIED
                        properties[
                        ]]
                11:12:56,721 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) parsed persistence unit definitions for war app2.war
                11:12:56,721 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) incrementing PU count for app2.war by 1
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) added javax.persistence.api:main dependency to app2.war
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) added org.jboss.as.jpa:main dependency to app2.war
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) added org.jboss.as.jpa.spi:main dependency to app2.war
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) added org.javassist:main dependency to app2.war
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) added (default provider) org.hibernate dependency to app2.war (since 1 PU(s) didn't specify jboss.as.jpa.providerModule)
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) added org.hibernate:main dependency to app2.war
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) Adding dependency on PU service service jboss.persistenceunit."app2.war#MyPU" for component javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) Adding dependency on PU service service jboss.persistenceunit."app2.war#MyPU" for component javax.servlet.jsp.jstl.tlv.ScriptFreeTLV
                11:12:56,723 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) Adding dependency on PU service service jboss.persistenceunit."app2.war#MyPU" for component javax.faces.webapp.FacetTag
                11:12:56,724 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) Adding dependency on PU service service jboss.persistenceunit."app2.war#MyPU" for component com.app2.servlet.App2Servlet
                11:12:56,724 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) Adding dependency on PU service service jboss.persistenceunit."app2.war#MyPU" for component com.sun.faces.config.ConfigureListener
                11:12:56,736 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) install persistence unit definitions for war app2.war
                11:12:56,736 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) adding 'vfs:/C:/Servers/wildfly-10.0.0.CR5-SNAPSHOT/bin/content/app2.war/WEB-INF/classes/' to annotation index map
                11:12:56,736 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) returning global (module) Persistence Provider org.hibernate.jpa.HibernatePersistenceProvider
                11:12:56,737 DEBUG [org.jboss.as.jpa] (MSC service thread 1-8) loaded persistence provider adapter org.jboss.as.jpa.hibernate5.HibernatePersistenceProviderAdaptor from classloader ModuleClassLoader for Module "org.hibernate:main" from local module loader @18e8568 (finder: local module finder @33e5ccce (roots: C:\Servers\wildfly-10.0.0.CR5-SNAPSHOT\modules,C:\Servers\wildfly-10.0.0.CR5-SNAPSHOT\modules\system\layers\base))
                11:12:56,738 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) service jboss.persistenceunit."app2.war#MyPU".__FIRST_PHASE__ is using the default data source 'java:jboss/datasources/ExampleDS'
                11:12:56,738 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) added PersistenceUnitService (phase 1 of 2) for 'service jboss.persistenceunit."app2.war#MyPU".__FIRST_PHASE__'.  PU is ready for injector action.
                11:12:56,738 TRACE [org.jboss.as.jpa] (MSC service thread 1-8) returning global (module) Persistence Provider org.hibernate.jpa.HibernatePersistenceProvider
                11:12:56,741 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 67) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'app2.war#MyPU'
                11:12:56,742 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) WFLYWELD0003: Processing weld deployment app2.war
                11:12:56,747 INFO  [org.hibernate.orm.deprecation] (ServerService Thread Pool -- 67) HHH90000001: Found usage of deprecated setting for specifying Scanner [hibernate.ejb.resource_scanner]; use [hibernate.archive.scanner] instead
                11:12:56,787 TRACE [org.jboss.as.jpa] (MSC service thread 1-1) install persistence unit definitions for war app2.war
                11:12:56,787 TRACE [org.jboss.as.jpa] (MSC service thread 1-1) adding 'vfs:/C:/Servers/wildfly-10.0.0.CR5-SNAPSHOT/bin/content/app2.war/WEB-INF/classes/' to annotation index map
                11:12:56,787 TRACE [org.jboss.as.jpa] (MSC service thread 1-1) returning global (module) Persistence Provider org.hibernate.jpa.HibernatePersistenceProvider
                11:12:56,787 TRACE [org.jboss.as.jpa] (MSC service thread 1-1) service jboss.persistenceunit."app2.war#MyPU" is using the default data source 'java:jboss/datasources/ExampleDS'
                11:12:56,788 TRACE [org.jboss.as.jpa] (MSC service thread 1-1) added PersistenceUnitService (phase 2 of 2) for 'service jboss.persistenceunit."app2.war#MyPU"'.  PU is ready for injector action.
                11:12:56,788 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."app2.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."app2.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "app2.war"
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                        at java.lang.Thread.run(Thread.java:745)
                Caused by: java.lang.IllegalStateException: WFLYCTL0075: Duplicate resource app2.war#MyPU
                        at org.jboss.as.controller.registry.AbstractModelResource$DefaultResourceProvider.register(AbstractModelResource.java:290)
                        at org.jboss.as.controller.registry.AbstractModelResource.registerChild(AbstractModelResource.java:169)
                        at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.addManagementConsole(PersistenceUnitServiceHandler.java:1132)
                        at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deployPersistenceUnitPhaseTwo(PersistenceUnitServiceHandler.java:680)
                        at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.addPuService(PersistenceUnitServiceHandler.java:291)
                        at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.handleWarDeployment(PersistenceUnitServiceHandler.java:202)
                        at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deploy(PersistenceUnitServiceHandler.java:131)
                        at org.jboss.as.jpa.processor.PersistenceCompleteInstallProcessor.deploy(PersistenceCompleteInstallProcessor.java:55)
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
                        ... 5 more
                
                11:12:56,860 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 67) WFLYUT0021: Registered web context: /app1
                11:12:56,913 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "app1.war" with deployment "app1.war"
                11:12:56,914 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
                WFLYCTL0184:    New missing/unsatisfied dependencies:
                      service jboss.deployment.unit."app2.war".beanmanager (missing) dependents: [service jboss.deployment.unit."app2.war".weld.weldClassIntrospector, service jboss.deployment.unit."app2.war".batch.environment]
                WFLYCTL0186:   Services which failed to start:      service jboss.deployment.unit."app2.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."app2.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "app2.war"
                11:12:56,915 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 1) WFLYDR0002: Content removed from location C:\Servers\wildfly-10.0.0.CR5-SNAPSHOT\standalone\data\content\07\aec00bc2300c5658e1fed728e72a45293a568b\content
                
                • 5. Re: Redeploy dependent WAR fails with duplicate resource error for persistence unit
                  smarlow

                  I do have a local fix that I pushed to https://github.com/scottmarlow/wildfly/tree/WFLY-4908_cleanupmanagementconsole, that deals with part of the problem.  I think that more changes are needed though to allow one application deployment to express a dependency on a PersistenceUnitService that is part of a different application.

                   

                  Currently, within an application deployment, the dependency from EE component to PersistenceUnitService is setup automatically. 

                   

                  If application-2 has a dependency on an application-1 PersistenceUnitService, applicaition-2 should stop, when application-1 is stopped (e.g. redeployed).  At least that is what I would expect to happen.

                   

                  Scott