Wildfly DuplicateServiceException

KamilJ picture KamilJ · Feb 13, 2015 · Viewed 21.4k times · Source

I have created simple EAR application using Maven archetype: wildfly-javaee7-webapp-ear-blank-archetype/8.2.0.Final

http://s17.postimg.org/cy8zbpiu7/Zrzut_ekranu_z_2015_02_13_23_15_10.png
My log from starting wildFly:

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
    23:08:04,244 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
    23:08:04,690 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
    23:08:04,787 INFO  [org.jboss.as] (MSC service thread 1-8) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
    23:08:06,596 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015014: Re-attempting failed deployment Przychodnia-ear.ear
    23:08:06,601 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found Przychodnia-ear.ear in deployment directory. To trigger deployment create a file called Przychodnia-ear.ear.dodeploy
    23:08:06,628 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
    23:08:06,662 INFO  [org.xnio] (MSC service thread 1-7) XNIO version 3.3.0.Final
    23:08:06,686 INFO  [org.xnio.nio] (MSC service thread 1-7) XNIO NIO Implementation Version 3.3.0.Final
    23:08:06,806 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
    23:08:06,813 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
    23:08:06,828 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
    23:08:06,864 INFO  [org.jboss.remoting] (MSC service thread 1-7) JBoss Remoting version 4.0.6.Final
    23:08:06,867 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
    23:08:06,867 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
    23:08:06,887 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
    23:08:06,893 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
    23:08:06,902 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.4)
    23:08:06,905 INFO  [org.jboss.as.security] (MSC service thread 1-8) JBAS013170: Current PicketBox version=4.0.21.Final
    23:08:06,943 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
    23:08:06,979 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)
    23:08:06,982 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010417: Started Driver service with driver-name = h2
    23:08:06,982 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010417: Started Driver service with driver-name = postgres
    23:08:07,024 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017502: Undertow 1.1.0.Final starting
    23:08:07,021 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting
    23:08:07,101 INFO  [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service
    23:08:07,103 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
    23:08:07,294 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /opt/wildfly-8.2.0.Final/welcome-content
    23:08:07,325 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017525: Started server default-server.
    23:08:07,342 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017531: Host default-host starting
    23:08:07,724 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:28080
    23:08:08,159 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) JBAS015012: Started FileSystemDeploymentService for directory /opt/wildfly-8.2.0.Final/standalone/deployments
    23:08:08,164 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
    23:08:08,166 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/PostgreSql/Przychodnia]
    23:08:08,171 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "Przychodnia-ear.ear" (runtime-name: "Przychodnia-ear.ear")
    23:08:08,361 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015973: Starting subdeployment (runtime-name: "Przychodnia-ejb.jar")
    23:08:08,362 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015973: Starting subdeployment (runtime-name: "Przychodnia-web.war")
    23:08:09,021 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final
    23:08:09,070 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011401: Read persistence.xml for primary
    23:08:09,210 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."Przychodnia-ear.ear".FIRST_MODULE_USE: org.jboss.msc.service.StartException in service jboss.deployment.unit."Przychodnia-ear.ear".FIRST_MODULE_USE: JBAS018733: Failed to process phase FIRST_MODULE_USE of deployment "Przychodnia-ear.ear"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_31]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_31]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_31]
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS010464: Exception deploying datasource java:jboss/datasources/PostgreSql/Przychodnia
        at org.jboss.as.connector.deployers.ds.processors.DsXmlDeploymentInstallProcessor.deploy(DsXmlDeploymentInstallProcessor.java:140)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
        ... 5 more
    Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.data-source.java:jboss/datasources/PostgreSql/Przychodnia is already registered
        at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:158) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:235) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:767) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2401) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2401) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:317) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.as.connector.deployers.ds.processors.DsXmlDeploymentInstallProcessor.startDataSource(DsXmlDeploymentInstallProcessor.java:338)
        at org.jboss.as.connector.deployers.ds.processors.DsXmlDeploymentInstallProcessor.deploy(DsXmlDeploymentInstallProcessor.java:137)
        ... 6 more

    23:08:09,220 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "Przychodnia-ear.ear")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"Przychodnia-ear.ear\".FIRST_MODULE_USE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"Przychodnia-ear.ear\".FIRST_MODULE_USE: JBAS018733: Failed to process phase FIRST_MODULE_USE of deployment \"Przychodnia-ear.ear\"
        Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS010464: Exception deploying datasource java:jboss/datasources/PostgreSql/Przychodnia
        Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.data-source.java:jboss/datasources/PostgreSql/Przychodnia is already registered"}}
    23:08:09,281 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "Przychodnia-ear.ear" (runtime-name : "Przychodnia-ear.ear")
    23:08:09,285 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
    JBAS014777:   Services which failed to start:      service jboss.deployment.unit."Przychodnia-ear.ear".FIRST_MODULE_USE: org.jboss.msc.service.StartException in service jboss.deployment.unit."Przychodnia-ear.ear".FIRST_MODULE_USE: JBAS018733: Failed to process phase FIRST_MODULE_USE of deployment "Przychodnia-ear.ear"

    23:08:09,411 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
    23:08:09,417 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
    23:08:09,418 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: WildFly 8.2.0.Final "Tweek" started (with errors) in 5696ms - Started 227 of 280 services (3 services failed or missing dependencies, 88 services are lazy, passive or on-demand)
    23:08:09,568 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015974: Stopped subdeployment (runtime-name: Przychodnia-ejb.jar) in 27ms
    23:08:09,571 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015974: Stopped subdeployment (runtime-name: Przychodnia-web.war) in 29ms
    23:08:09,573 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment Przychodnia-ear.ear (runtime-name: Przychodnia-ear.ear) in 32ms
    23:08:09,699 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "Przychodnia-ear.ear" (runtime-name: "Przychodnia-ear.ear")
    23:08:09,701 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
    JBAS014775:    New missing/unsatisfied dependencies:
          service jboss.module.service."deployment.Przychodnia-ear.ear.Przychodnia-ejb.jar".main (missing) dependents: [service jboss.deployment.subunit."Przychodnia-ear.ear"."Przychodnia-ejb.jar".FIRST_MODULE_USE] 
          service jboss.module.service."deployment.Przychodnia-ear.ear.Przychodnia-web.war".main (missing) dependents: [service jboss.deployment.subunit."Przychodnia-ear.ear"."Przychodnia-web.war".FIRST_MODULE_USE] 
    JBAS014777:   Services which failed to start:      service jboss.deployment.unit."Przychodnia-ear.ear".FIRST_MODULE_USE

    23:08:14,325 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015003: Found Przychodnia-ear.ear in deployment directory. To trigger deployment create a file called Przychodnia-ear.ear.dodeploy

Przychodnia-ds.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- This is an unmanaged datasource. It should be used for proofs of concept 
   or testing only. It uses H2, an in memory database that ships with JBoss 
   AS. -->
<datasources xmlns="http://www.jboss.org/ironjacamar/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">

    <datasource jndi-name="java:jboss/datasources/PostgreSql/Przychodnia" pool-name="Przychodnia"
        enabled="true" use-java-context="true">
        <connection-url>jdbc:postgresql://localhost:5432/Przychodnia;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1</connection-url>
        <driver>postgres</driver>
        <security>
            <user-name>postgres</user-name>
            <password>postgres</password>
        </security>
    </datasource>
</datasources>

Persistence.xml:

<?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="primary">
      <!-- If you are running in a production environment, add a managed 
         data source, this example data source is just for development and testing! -->
      <!-- The datasource is deployed as <EAR>/META-INF/Przychodnia-ds.xml, you
         can find it in the source at ear/src/main/application/META-INF/Przychodnia-ds.xml -->
      <jta-data-source>java:jboss/datasources/PostgreSql/Przychodnia</jta-data-source>
      <properties>
         <!-- Properties for Hibernate -->
         <property name="hibernate.hbm2ddl.auto" value="update" />
         <property name="hibernate.show_sql" value="false" />
      </properties>
   </persistence-unit>
</persistence>

Maven application.xml:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" version="7">
  <display-name>Przychodnia-ear</display-name>
  <module>
    <web>
      <web-uri>Przychodnia-web.war</web-uri>
      <context-root>/Przychodnia-web</context-root>
    </web>
  </module>
  <module>
    <ejb>Przychodnia-ejb.jar</ejb>
  </module>
  <library-directory>lib</library-directory>
</application>

Answer

Viacheslav Shalamov picture Viacheslav Shalamov · Aug 12, 2015

in your ../wildfly-X.X.X/standalone/configuration/standalone.xml you'll se the following:

<deployments>
    <deployment name="your_file.war" runtime-name="your_file.war">
        <fs-archive path=".../your_file.war"/>
    </deployment>
    ...
</deployments>

This causes the DuplicateServiceException. Just remove it.