JBoss hangs during startup if application calls System.exit() from initialisation code

Solution Verified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 7.x
    • 6.x

Issue

JBoss is hanging during startup, and trying to shut it down does not work.

In the thread dump, there is:

"ServerService Thread Pool -- 90" prio=10 tid=0x00007f89f0249000 nid=0x1f52 in Object.wait() [0x00007f89b90fa000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x00000006d67f6080> (a java.lang.Thread)
	at java.lang.Thread.join(Thread.java:1260)
	- locked <0x00000006d67f6080> (a java.lang.Thread)
	at java.lang.Thread.join(Thread.java:1334)
	at java.lang.ApplicationShutdownHooks.runHooks(ApplicationShutdownHooks.java:106)
	at java.lang.ApplicationShutdownHooks$1.run(ApplicationShutdownHooks.java:46)
	at java.lang.Shutdown.runHooks(Shutdown.java:123)
	at java.lang.Shutdown.sequence(Shutdown.java:167)
	at java.lang.Shutdown.exit(Shutdown.java:212)
	- locked <0x00000006d671a8c8> (a java.lang.Class for java.lang.Shutdown)
	at java.lang.Runtime.exit(Runtime.java:109)
	at java.lang.System.exit(System.java:961)
	at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:222)
	at javax.servlet.GenericServlet.init(GenericServlet.java:242)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194)
	- locked <0x0000000713e05dc8> (a org.apache.catalina.core.StandardWrapper)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1100)
	- locked <0x0000000713e05dc8> (a org.apache.catalina.core.StandardWrapper)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3591)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3798)
	- locked <0x0000000713a093c8> (a org.apache.catalina.core.StandardContext)
	at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156)
	at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60)
	at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)

Resolution


Disclaimer: Links contained herein to an external website(s) are provided for convenience only. Red Hat has not reviewed the links and is not responsible for the content or its availability. The inclusion of any link to an external website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.


Solve the problem causing the application to call System.exit()

Applications should not call System.exit() in any hypothesis.
For Liferay applications, this has been filed as a bug Content from issues.liferay.com is not included.LPS-32825

Root Cause

The application is calling System.exit() in it's startup code. EE applications should never call System.exit().

When called from startup code, the thread blocks inside System.exit() so that it never returns. Meanwhile, the JBoss EAP shutdown thread causes all applications to undeploy, but the triggering application cannot undeploy until it finishes deploying. This leads to a wait-deadlock between the thread running the application Startup code and the thread(s) processing JBoss EAP shutdown.

Diagnostic Steps

Collect a thread dump and see if there is a thread which has called System.exit() from application startup.

Components
Category
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.