Take_Thread_Dump_in_JBoss

Ref: 

https://developer.jboss.org/wiki/GenerateAThreadDumpUsingJMXConsoleJBossAS3456

http://stackoverflow.com/questions/20377281/how-to-take-thread-dump-in-linux-environment-using-jboss-eap-5-1-server

Generate a thread dump using JBoss Web Console

 

In order to generate a thread dump:

 

1. Open the JMXConsole (for example: http://localhost:8080 )

2. Navigate to jboss.system:type=ServerInfo mbean (hint: you can probably just CTRL-F and enter type=ServerInfo in the dialog box)

3. Click on the link for the Server Info mbean.

4. Navigate to the bottom where it says "listThreadDump"

5. Click it and get your thread dump

6. Enjoy your thread dump (and/or debug your problem, send it up to JBoss support or attach it to your bug report)

 

Notes:

 

If you are using Internet Explorer you should use File -> Save As to save the output instead of copying the data to a text editor.  For some reason when you copy the text from Internet Explorer the line breaks are not copied and all of the output ends up on a single line.

 =================================================================================

Generate a Thread Dump using Twiddle

Alternatively you can use twiddle to execute the listThreadDump method and pipe the returned HTML directly to file i.e.

 

<JBOSS_HOME>/bin/twiddle invoke "jboss.system:type=ServerInfo" listThreadDump > threads.html

====================================================================================

Generate a Thread Dump using jstack

The easiest way would be to get the PID of the JBoss server and jstack, which is part of the HotSpot JDK (and OpenJDK, I believe), then write the output to a new file. If the PID of JBoss is 1234:

jstack -l 1234 >> myThread.dmp

The double arrow bracket will create the file if it does not exist, or append to it if it does exist, so you can take multiple thread dumps and save to the same file (useful for seeing changes over time).

You can find the PID of JBoss either using the linux ps command and grepping for Java:

ps aux | grep java

Or simply with JPS (another tool which comes with the JDK) and the "-v" verbose option:

jps -v

This answer is applicable to any Java application.