Project

General

Profile

Actions

How to get Java thread dump in Jboss

This guide is only applicable to:
  • Linux OS with netcat package installed
  • Jboss AS 4.x (it may work for Jboss 5.x)
Steps
  1. first, find out the Jboss's web listening port and address.
    1. the listening port can be found in:
      ${Jboss Directory}/server/${profile name}/deploy/jboss-web.deployer/server.xml
      
    2. the listening address can be found through netstat:
      $ netstat -tuna | grep ${listening port}
      
  2. ssh to the target server
  3. cd to /tmp
  4. execute the following command:
    This command will output the result to current directory with a file named, thread_dump.${timestamp}
    • Template:
      $ echo -e "GET /jmx-console/HtmlAdaptor?action=invokeOp&name=jboss.system%3Atype%3DServerInfo&methodIndex=1 \n\n"  | nc listen_ip listen_port | cat > thread_dump.$(date +%Y-%m-%d_%H_%M_%S)
      
      • replace listen_ip with the listening IP
      • replace listen_port with the listening port
    • Example:
      $ echo -e "GET /jmx-console/HtmlAdaptor?action=invokeOp&name=jboss.system%3Atype%3DServerInfo&methodIndex=1 \n\n"  | nc 127.0.0.1 8080 | cat > thread_dump.$(date +%Y-%m-%d_%H_%M_%S)
      
  5. append the .html to the output's filename
    From:
    thread_dump.2010-11-11_12_08_26
    

    To:
    thread_dump.2010-11-11_12_08_26.html
    
  6. download the output file to local machine
  7. done.

Updated by chin-yeh almost 14 years ago · 4 revisions