How to solve Failed to start service jboss.deployment.unit

In this short article we will learn how to solve a common error which you can hit at deployment time: “failed to start service jboss.deployment.unit”.

Understanding the deployment failure

The “Failed to start service jboss.deployment.unit” error in WildFly typically occurs when there is an issue with the deployment of an application or module. When WildFly attempts to start the deployment, it encounters an error and is unable to start the service.

There are several possible reasons for this error, including:

  1. Incorrect configuration: The deployment may contain configuration settings that are not valid or are conflicting with other settings in the application server. This can cause WildFly to fail to start the service.
  2. Dependency issues: The deployment may have dependencies on other modules or services that are not available or are not properly configured in WildFly. This can cause WildFly to fail to start the service.
  3. Corrupted deployment: The deployment package or its contents may be corrupted or incomplete, causing WildFly to fail to start the service.

Let’s see a practical example. Check the following error log:

16:55:43,635 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "helloworld-mdb.war" (runtime-name: "helloworld-mdb.war")
16:55:43,642 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."helloworld-mdb.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."helloworld-mdb.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "helloworld-mdb.war"
	at [email protected]//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:189)
	at [email protected]//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
	at [email protected]//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
	at [email protected]//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
	at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
	at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
	at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jboss.msc.service.ServiceNotFoundException: service jboss.ejb.default-resource-adapter-name-service not found

As you can see, we have attempted to deploy the helloworld-mdb.war application but it failed. The error message does not help too much in finding the root cause. However, if you look into the Stack Trace you will see what is causing the error:

failed to start service jboss.deployment.unit

As you can see, it’s missing the service jboss.ejb.default-resource-adapter-name-service.

To solve the issue, you should therefore find out why the above service is not available. In this case, there can be two potential causes for this issue:

  • You are using a profile which does not include this service (f.e. the standalone.xml configuration)
  • You are missing the resource adapter indicated in your configuration (f.e. the activemq-ra-rar Resource adapter)
 <mdb>
       <resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:activemq-ra.rar}"/>
       <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
 </mdb>

In other cases, there are no missing services but you are trying to provide a service with a faulty configuration. See the following example:

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.unit."crc-ds.xml".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."crc-ds.xml".PARSE: Failed to process phase PARSE of deployment "mysql-ds.xml"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_45]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_45]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Received non-all-whitespace CHARACTERS or CDATA event in nextTag(). at [row,col {unknown source}]: [95,0]

In the above example, there is a failure in parsing a Datasource configuration file (mysql-ds.xml) which you have added in your application or in the deployments folder.

As a rule of thumb to solve this error, always check which is the Root cause that causes your deployment to fail. In most cases, the Caused by contains the root cause.

Finally, a complex Framework can create a dozen or more Caused by: sections. Therefore, a good strategy is to jump down those looking for your own code: Caused by: com.myproject. This is your first step to isolate the problem.

Conclusion

By following these steps, you can diagnose and resolve the “Failed to start service jboss.deployment.unit” error in WildFly and get your application up and running again.