How-to make Thread dump of Java and Weblogic Server

There are several ways to make a thread dump. Below a list of possible ways to to it:

Option 1:

  1. Log in on the console
    1. Log into the console
    2. Go to Environment/Servers/[server]/Server Start
    3. Insert the following line to the “Arguments”:
      
      -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=[PATH]
      
      
    4. Save and activate the session
  • [server] -> The server for which you want to make a thread dump
  • You need a licence to use -XX:+UnlockDiagnosticVMOptions in the production environments. This option is not needed to make a thread dump but needed to make a flight recorder.
  •  [PATH] -> Location where the dump file must be created (ex: /tmp/wls1_dump.log)

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

Option 2:

  1. Open a shell session
    1. Find the process id [PS ID] of the Weblogic instance (ps –ef | grep –i weblogic, 2e  column)
    2. Execute command: kill -3 [PS ID]
  2. Thread dumps has to be done several times to make a good analyse. Move the created dump file to another name or location and repeat the 2b 4 more times.
  3. If you skip the first step (1a and 1b), the dump will be set into the standard out.

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

Option 3: It is possible to make a thread dump from the console. This dump will contain less details than the option 1.

  1. Log into the console
  2. Go to Environment/Servers/[server]/Monitoring/Threads
  3. Click “Dump Thread Stacks

dumpthreads

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

Option 4:

  1. Open a shell session
  2. Find the process id [PS ID] of the Weblogic instance using the command jcmd or jps
  3. Execute jstack [PS ID]

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

Option 5: JDK 7:

  1. Open a shell session
  2. Find the process id [PS ID] of the Weblogic instance using the command jcmd or jps
  3. Execute jcmd [PS ID] Thread.print

 jcmd [PROCESS_ID] Thread.print > /PATH/tracedump.trc

To make 5 thread dumps, with an interfall of 1 minute:

for i in {1..5}; do
echo "Log file written to: /tmp/$HOSTNAME-Thread.print_$(date +"%Y-%m-%d-%H%M%S")";
jcmd $(jcmd |grep weblogic.Server | cut -d' ' -f1)
Thread.print > /tmp/$HOSTNAME-Thread.print_$(date +"%Y-%m-%d-%H%M%S").log ;
sleep 59;
done

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

Option 6:

  1. Open a shell session
  2. Find the process id [PS ID] of the Weblogic instance using the command jcmd or jps
  3. Execute jcmd [PS ID] GC.heap_dump [heap_file]
  4. Execute jvisualvm –openfile [heap_file]
  5. Jvisualvm will open.
=====================================================================

Option 7:

  1. Open a shell session
  2. Execute: jmc (Java Misscion Control)

It is an application where you canmonitor running JVM, can attach triggers to make thread dumps and a lot of other features

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s