Sometimes when I stop my Liferay module (for instance when I put a new version of its JAR in deploy/
) the module refuses to stop.
While the module should go to "Resolved" state, it stays in the "Stopping" state forever:
Usually it is due to a thread not terminated somewhere, or a network connection not properly closed, and it is often a pain to investigate.
My question: How to find out more efficiently what this Liferay module's problem is?
What I tried:
- In Gogo Shell
diag <module id>
does not seem to provide any valuable information about why the module refuses to leave the "Stopping" state. - jstack outputs thousands of lines, the vast majority of which is outside of the Liferay module in question. If there was a way to show jstack information for only my module that would be wonderful.
First, find the PID of your webapp server:
Adapt the command if you are running another server than tomcat, or if you have several instances running.
Then, dump all threads of that server to a file:
Where 12345 is the PID you found in the first step.
Then, look at the source code of your bundle, and find the service activator. It typically looks like this:
Take note of:
For instance in the example above they are
fr.free.nrw
,ServiceActivator
andstop
, and from these three get the full namefr.free.nrw.ServiceActivator.stop
.Now open
jstack.txt
and search for the full name. Even though the file is thousands of lines long, there will most probably only be one hit, and that is the problematic thread:In this file, go up to the beginning of the paragraph, which will be something like this:
With this information in hand, you will known what kind of threading problem is going on, and you will be able to solve it with usual Java thread debugging techniques (1 2).