Take thread dump of application without tomcat restart

1.6k views Asked by At

I had to create thread dump of web application in tomcat runned as a service without need to restart tomcat. I tried to attach jconsole, jvisualvm, jstack, but without success.

  • Tomcat is not jmx remote enabled. (But can't introduce properties - can't restart it)
  • I tried to execute applications from the same user as the service, change TEMP, TMP folders
  • I want to execute it locally - on the same server as tomcat as no configuration should be needed (hence no restarting) ("Note: This configuration is needed only if you are going to monitor Tomcat remotely. It is not needed if you are going to monitor it locally, using the same user that Tomcat runs with.")
  • In jConsole process is showed grayed, sometimes not visible - could not attach it
  • In jStack: Insufficient memory or insufficient privilages to attach
  • Tomcat is running on Windows machine

Any ideas?

3

There are 3 answers

1
Klara On BEST ANSWER

I would have recommended jcmd, but I think it has the same problems with local attach as jstat and the other tools.

According to the following two google hits, "psexec -s jstack PID" seems to be a solution (which I have not tried)

https://www.assetbank.co.uk/support/documentation/knowledge-base/how-to-take-a-java-thread-dump/ https://access.redhat.com/solutions/19170

1
mindas On

If running on Unix, send kill -3 <pid>. This will print the thread dump to catalina.out.

You must be the same user as Tomcat service is running.

0
Konstantin Kolinko On