How to take thread dumps on weblogic server

Whenever we frequently encounter stuck threads or hogging threads on weblogic, first option we have is to take thread dumps and analyze them. This post talks about how to take thread dumps.
There are different ways of taking dumps:
First way is taking from unix using kill command
1.      Login to unix box
2.      Find out PID of your server instance.
ps –ef | grep –i “adminServer”
This will give you pid of your server
3.      kill -3 PID
Now, very often I get confused, where does out of this go? Where did my dump go? Well, output of this is sent to “.out” file of server.
Server.out file contains lot of log and how to identify or copy them; it might be tedious task to perform. So, easiest way is to redirect these entries into log. So, as we can use tail command to see changes in file dynamically. Let us use this tail command and then redirect output to another file. And yes, we need to run this in back ground. We can do it using “&” at end of command. Command looks as below:
 tail –f ServerOutFile >> LocationAndDumpFileName &
e.g. tail –f adminServer.out >> /tmp/threadDump1.dmp &
Now, if you run kill -3 pid, the output will found in /tmp/threadDump1.dmp
But, wait a second, tail command will keep running until you stop it, so don’t forget to kill it. Ok but then you need to find the pid and kill it. So, instead if we store pid now and then kill process using that pid it will be easier. So let us modify the command.
tail –f adminServer.out >> /tmp/threadDump1.dmp & PID_Tail=$1
now, $PID_Tail contain PID of tail command which can be used to kill tail. So sequence, would be,
ps –ef | grep –i “adminserver”  --> get pid

tail –f adminServer.out >> /tmp/threadDump1.dmp & PID_Tail=$1

kill -3 pid

kill -9 PID_Tail
You can analyze thread dumps at /tmp/threadDump1.dmp

Second way is to use wlst commands. Run setDomainEnv.sh or run wlst from $WL_HOME/common/bin.
First connect to server using t3 protocol and then take dumps. Commands as are below:
connect(‘adminUsername’,’Password,’t3://hostname:serverpot’)
executeDump(name=’jvm.threads’,outputFile=’ThreadDumpLocation’,args={‘context’:’true’})
So for adminServer :

connect('adminUsername','Password','t3://hostname:serverport')

executeDump(name='jvm.threads',outputFile='ThreadDumpLocation',args={'context':'true'})

So for adminServer :

connect('weblogic','password','t3://localhost:7001')

executeDump(name='jvm.threads', outputFile='/tmp/adminServerThreads.dmp',args={'context':'true'})

For managed server running on port 8001, it can be

connect('weblogic','password','t3://localhost:8001')

executeDump(name='jvm.threads', outputFile='/tmp/ManagedServerThreads.dmp',args={'context':'true'})
Third way to take thread dumps from weblogic admin console. Navigate to
Server ServerName — Monitoring — ThreadsDump Thread Stacks
You can copy these dumps and use them. Please refer to screen shot below:


Hope this post will help you take thread dumps.

Leave Comment

Your email address will not be published. Required fields are marked *