views:

3806

answers:

7

I'm launching a Weblogic application inside Eclipse via the BEA Weblogic Server v9.2 runtime environment. If this were running straight from the command-line, I'd do a ctrl-BREAK to force a thread dump. Is there a way to do it in Eclipse?

A: 

Did you try to launch your eclipse with java.exe instead of javaw.exe (in your eclipse.ini) ?

That might give you the console you need, as described in this bug and in this message.

Other ideas (in term of java options) could be derived from this other SO question.

VonC
+4  A: 

Indeed (thanks VonC to point to the SO thread), Dustin, in a comment to his message, points to jstack.

I have run a little Java application (with GUI) in Eclipse, I can see the related javaw.exe in Windows' process manager and its PID, 7088 (it is even simpler in Unix, of course).

If I type at a command prompt jstack 7088, I have the wanted stack dump per thread.
Cool.

Would be better if we could do that directly from Eclipse, but that's already useful as is.

PhiLho
Warning: we do not know the platform used to launch eclipse/weblogic: if it is windows, jstack is not supported with java1.5, and only partially supported with 1.6
VonC
it's easy to launch external tools directly from Eclipse: menu "Run -> External Tools" or the toolbar button next to the "run" button (add a string_prompt for the PID)
Carlos Heuberger
+2  A: 

You can do it when you are in debug mode: go to the debug view in the debug perspective, click on the process you have launched and click on pause, you will get a graphical stack of all your processes.

Note : this also works when using remote debugging, you do not need to launch weblogic from eclipse, you can launch it on its own, open the debugging ports and create a "remote java application debug configuration" for it.

Denis R.
yep, but you need to add this to the JVM: set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n
djangofan
+3  A: 

check SendSignal: http://www.latenighthacking.com/projects/2003/sendSignal/

lesliel
Oh my gosh! I cant believe I never knew about Ctrl-Break until now!!!!!!!!!!!!!!!!!! THank you for this post that led mt to that !!!!!!!!!!
djangofan
+2  A: 

StackTrace is another option that you could try. From the features:

Thread dump for Java processes running as a Windows service (like Tomcat, for example), started with javaw.exe, applets running inside any browser or JVMs embedded inside another process. StackTrace works on Windows, Linux and Mac OS X.

Simon Lieschke
+1  A: 

Eclipse Wiki: How to Report a Deadlock lists all possible options of creating a thread dump in Eclipse. Depending on the concrete situation, one or the other may work better -- my personal favorite on Windows is the Adaptj Stacktrace tool.

Martin Oberhuber
A: 

You can connect through the JVisualVM and get a thread dump. Just right click on the application node from the Applications tree and select "Thread dump"

Wiraj