views:

23

answers:

2

I have a Tomcat running as a Windows Service, and those are known not to work well with jstack. jconsole is working well, on the other hand, and I can see stacks of individual threads (I'm connecting to "localhost:port" to access it).

How can I use jconsole or a similar tool to dump all the thread stacks into a file? (similar to jstack)

A: 

You can use the ThreadMXBean management interface.

This FullThreadDump class demonstrates the capability to get a full thread dump and also detect deadlock remotely using JMX.

dogbane
A: 

Here's another code sample that will write a stack dump to a file:

http://pastie.org/1229845

We use this over JMX to give us an approximation of the stack dump you get when you send a signal to a JVM.

Gray