views:

40

answers:

2

I've looked through couple of articles here such as:

http://stackoverflow.com/questions/2124672/java-stack-dump-on-windows

http://stackoverflow.com/questions/239544/thread-dump-programmatically-jdi-java-debugger-interface But didnt catch the exact answer.

The problem: There is a Java5 Application on Windows that's runs as a service (so we dont have a console where we are able to use Ctrl+Break for Dumping). And sometimes Application hangs and we need a thread dump.

We've tried "jstack" but it doesnt work in our env (we found out that its Java6 only compatible).

So we made a C++ app that calls thread dump via .dll call method attaching to the Java app process, and because of this it needs Local Admin rights, that is not so good.

So we'd like other options that works without admin rights and works with Java 5 without lots of rework of existing code.

Method with Printing in LOOP thread dumps (Thread.getAllStackTraces()) is not an option because we need to refactor lots of applications in order to make it work.

So that just an util that works from "outside" of applications would be a best option.

Thanks in advance!

A: 

One option is to dump all the information using jmap, and then analyzing it using other tool.

jmap -dump:format=b,file=<filename>.hprof <jvm_pid>

I am not sure, buy I think it will work on Java 5.

References:

Daniel H.
A: 

You can attach to the process with JConsole to detect deadlocks and get stack traces of the threads. For more information, see here: http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html

DNN