title: JBoss EAP 7.1 Deployment Failed : WFLYCTL0013: Operation ("deploy") failed
body: <p>My Project is war deployment. </p>
  
  <blockquote>
    <p>XXX.war</p>
  </blockquote>
  
  <p>For my project there is a datasource (ds) that is installed in jboss.</p>
  
  <p>Also <code>XXX.war</code> has maven dependency on a <code>xxx-domain.jar</code> ,which deals with hibernate/persistence configurations.</p>
  
  <p>Here is  my <code>persistence.xml</code></p>
  
  <pre><code>&lt;persistence version="2.0"
     xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="
          http://java.sun.com/xml/ns/persistence
          http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
     &lt;persistence-unit name="primary"  transaction-type="JTA"&gt;
         &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
        &lt;jta-data-source&gt;java:/xxxDS&lt;/jta-data-source&gt;
        &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;      
        &lt;properties&gt;
           &lt;property name="hibernate.show_sql" value="true" /&gt;
           &lt;property name="hibernate.session_factory_name" value="XXXSessionFactory"/&gt;
           &lt;property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/&gt;
           &lt;property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" /&gt;
        &lt;/properties&gt;
     &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>This is <code>hibernate.cfg.xml</code></p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory name="java:jboss/XXXSessionFactory"&gt;
       &lt;property name="connection.datasource"&gt;java:xxxDS&lt;/property&gt;
        &lt;property name="show_sql"&gt;false&lt;/property&gt;
        &lt;property name="dialect"&gt;org.hibernate.dialect.Oracle9Dialect&lt;/property&gt;
        &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
        &lt;mapping resource="com/xxx/model/XXXModel.hbm.xml"/&gt;
  
      &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>This 2 configurations is present in  <code>xxx-domain.jar</code>.</p>
  
  <p>When I was trying to deploy it using <code>jboss-as:deploy</code> . It's giving me the following error</p>
  
  <pre><code>15:58:22,288 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."XXX.war".FIRST_MODULE_USE: org.jboss.msc.service.StartException 
  in service jboss.deployment.unit."XXX.war".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment "XXX.war"
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
          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: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
          at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deployPersistenceUnitPhaseOne(PersistenceUnitServiceHandler.java:558)
          at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.addPuService(PersistenceUnitServiceHandler.java:279)
          at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.handleWarDeployment(PersistenceUnitServiceHandler.java:206)
          at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deploy(PersistenceUnitServiceHandler.java:134)
          at org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor.deploy(PersistenceBeginInstallProcessor.java:52)
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
          ... 5 more
  Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit."XXX.war#primary".__FIRST_PHASE__ is already registered
          at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:158)
          at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:235)
          at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:768)
          at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
          at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2555)
          at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
          at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2555)
          at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:317)
          at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deployPersistenceUnitPhaseOne(PersistenceUnitServiceHandler.java:554)
          ... 10 more
  
  15:58:22,292 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 23) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" =&gt; "XXX.war")]) - failure description: {
      "WFLYCTL0080: Failed services" =&gt; {"jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE" =&gt; "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"XXX.war\"
      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
      Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit.\"XXX.war#primary\".__FIRST_PHASE__ is already registered"},
      "WFLYCTL0412: Required services that are not installed:" =&gt; ["jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE"]
  }
  15:58:22,293 ERROR [org.jboss.as.server] (management-handler-thread - 23) WFLYSRV0021: Deploy of deployment "XXX.war" was rolled back with the following failure message:
  {
      "WFLYCTL0080: Failed services" =&gt; {"jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE" =&gt; "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"XXX.war\"
      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
      Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit.\"XXX.war#primary\".__FIRST_PHASE__ is already registered"},
      "WFLYCTL0412: Required services that are not installed:" =&gt; ["jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE"]
  </code></pre>
  
  <p>Could somebody please help me to figure out what is the issue ??</p>