Tuesday, April 7, 2009

Getting Thread Dumps or StackTraces

Stack trace can be obtained by issuing the following command

jstack <processid>

The output can also be redirected into any file.

Ref : http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstack.html

The thread dumps also can be obtained by the following command

kill -3

The thread dump will be appended to the application logs.

(Redirect the standard out (stdout) of the java command to a file. When you send a SIGQUIT signal to the java process, a thread dump is sent to the stdout)

To understand and analyse the thread dumps refer the following

http://weblogs.java.net/blog/bhaktimehta/archive/2007/05/obtaining_and_a.html

2 comments:

Andrew said...

Have you been able to generate thread dumps with the spring dm server? kill -3 (pid) doesn't work for me. I know that with a normal tomcat installation the thread stack will normally be redirected to $CATALINA_OUT. However, with the dm server I have looked through all the logs and found nothing and the command generates nothing on the STDOUT to collect.

Just curious if you have had any success and how you did it with the dm server.

-Andy

Sudheer Krishna said...

Yes i did get stack traces with the spring DM server.

Instead of kill -3 i ended up using
jstack processid > filename.txt

This gave me the proper traces in filename.txt.

Normally kill -3 adds the trace to the application log , but in the case of dm it did not wrk.

 
Free Domain Names @ .co.nr!