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,
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:
So for adminServer :
Third way to take thread dumps from weblogic admin console. Navigate to
Server — ServerName — Monitoring — Threads — Dump Thread Stacks