How to solve JBAS014803: Duplicate resource

This quick tutorial discusses how to fix the error β€œDuplicate resource” which you can find at start up or upon deployment of a resource on WildFly.

Which is the duplicate resource?

Firstly, we need to establish which is the resource is causing the error. Consider the following error message:

05:17:13,199 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 12) JBAS014613: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "MyDatabaseDS")
]) - failure description: "JBAS014803: Duplicate resource [
    (\"subsystem\" => \"datasources\"),
    (\"data-source\" => \"MyDatabaseDS\")
]"

In the above example, you have attempted to configure the resource MyDatabaseDS in WildFly. However, the server already contains a definition for that resource.

As a rule of thumb, check if your application attempts to re-define that resource definition as XML file. Either remove the definition from the standalone.xml file or from your application.

Another possibility is that the duplicate resource is the application which you are deploying:

06:20:50,037 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread)
 JBAS014612: Operation ("add") failed - address: ([("deployment" => "application.ear")]) - failure description:
"JBAS014803: Duplicate resource [(\"deployment\" => \"application.ear\")]"

In this case, we recommend restarting the application server in admin-only mode:

./standalone.sh --admin-only

Then from the CLI, remove the existing application:

undeploy application.ear

In addition, if you are copying applications under the deployments folder, we recommend deleting all the .failed files.

You should now be able to restart the application server and deploy your application.