Tuesday 19 June 2012

java thread dump (stack trace) in WebLogic


java thread dump (stack trace) in WebLogic


Why java thread dumps are required?
Sometimes we see a particular thread of the application deployed in Weblogic gets STUCK indifinetely and may require a restart to come out of it. This can happen for a number of reasons. To find out what the application was doing or waiting for which lead it to STUCK state, a thread dump is required to investigate the cause of this situation. The thread dump provides Java stack trace. A Java stack trace is a snapshot of the thread in a Java1 Virtual Machine (JVM). A stack trace can range from few lines to thousands of lines of diagnostics (this depends on how complex the application is).


1. Using kill -3


●● Unix operating systems have a command called 'kill' which sends different signals to a target running process or a daemon. A signal is a form of IPC (inter-process communication) that is used in the Unix operating systems to notify a process (its signal handler) that an event has occurred. Therefore, there are many uses for the kill command. For example, to kill (end / terminate) a process, signal SIGKILL (signal number 9) can be used. This cuases the process to end immediately.
●● Likewise, we can use kill -3 (signal SIGQUIT, quit and dump core) command to send a signal to the process whose dump we require. This signal causes the Java Virtual Machine to generate a stack trace of the process. This signal does terminate the process rather produces a dump.


kill -3 <PID>


●● where PID is the Java process ID in the operating system. Process ID can be found out using ps -ef command which lists all the processes running, and which can be further filetred using grep command with process name (e.g. java) or username as argument etc.


If you have started the Weblogic server using nohup, then dump is redirected to nohup.out.


2. Using jstack utility


By default, the output is redirected to stdout. This can be changed in Weblogic start up script using JAVA_OPTION.
jstack <PID>
To get a forced thread dump (when a process is not responding to jstack), use -F option.


3. Using WebLogic Admin console


Login to AdminConsole >>> Admin Server >>> Monitoring >>> Threads >>> Dump Thread Stacks


4. Using Weblogic Admin utility


java weblogic.Admin -url t3://WLS_hostname:Port -username <user> -password <password> GET -pretty -type JVMRuntime
Before running the above utility, you may have to source the setDomainEnv.sh from the Weblogic_domain_home/bin directory.




Cheers !!!!!


>>>> If you feel that you would like to read on some topics, please feel free to put a comment in the blog, I would definitely help. If you need any help for any Oracle Apps or Database related issues, put a comment.

1 comment:

  1. Nice Post! I appreciate to you for this post. Really you are the best. Oracle Java Dumps

    ReplyDelete