Taking Thread dumps on Tomcat on windows

Hi All,

Sometime we start facing problems with Tomcat abrupt hang problem.The threads never go anywhere near the max.  The
CPU usage never goes above high usage.  The memory does not get used up. simply making the situation hang on server.

In that case only thing left with us is to analyse the thread dumps.  Taking thread dumps is very easy on windows using jstack command. Only thing we need to do is to take process id and fetch the thread dumps, By default all logs redirects to catalina.log but we can force the logs to some external files using dos command.

Follow the Below steps to fetch the Threads Dumps on Tomcat,

Step 1: Press the ctrl+alt+del(task manager) and get the Tomcat process id from running processes list. If PID is not coming then simply click on view->select columns -> select the PID(Process identifier).

Step 2: Open the command console and type the below command
jstack -l    e.g    jstack -l 2268

After that you will see the thread dumps on the Tomcat console itself. If you want to redirect the logs to some external file then use the below command.

jstack -l    e.g    jstack -l 2268 > c:\tomcat_threads.log (make sure this file should be created first)


There is also one more workaround to fetch the same. Just set the focus on the tomcat console and press ctrl+break, you will see the same output on the console.

To read the Thread dumps, simply use the Samurai the one of best tool to analyse the thread dumps.

Hope this Helps.

R Vashi

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.