Friday, August 3, 2012

Different ways to take thread dumps in WebLogic Server


Dear All, 

Best Wishes… @@@@ Hope Everyone doing well..

Today we will talk about different ways to take thread dumps in Weblogic server environment.

Thread dumps are essential diagnosis information used to analyze and troubleshoot performance related issues such as server hangs, deadlocks, slow running, idle or stuck applications, slow database interactions etc...

WebLogic Server (WLS) and Java offer several ways to generate thread dumps, they are detailed below. It is always recommended to obtain the thread dumps by using operating system (OS) commands rather than by using Java classes or the Administration Console, because if the console is hanging, users won't be able to connect to it to issue thread dumps.

Option 1) Use operating system commands to get the thread dumps when WLS starts up from a command-line script:

On Windows OS, thread dumps can be created by

<ctrl>+<break> -- the thread dumps are generated in the server stdout

On POSIX-compliant platforms (e.g. Solaris and Linux), first identify the process ID (pid) using

 ps -ef | grep java, then run

kill -3 <pid> 2>&1

Signal 3 is equivalent to SIGQUIT. Note that in Solaris, the thread dump is generated in the current shell, but in Linux, the thread dump is generated in the shell which started the java process specified by the pid.

Option 2) Using beasvc (up to WLS 10.3.5 included):

beasvc -dump -svcname:<service_name>
[Note: service_name is the Windows service that is running the server instance (e.g. mydomain_myserver)]

Option 3) Using wlsve (from 10.3.6/12.1.1):

wlsve -dump -svcname:<service_name>

Option 4)
Using weblogic.WLST:

setDomain.cmd or setDomain.sh depending on the OS
 
java weblogic.WLST 
connect("<username>","<password>","t3://<url>:<port>")
threadDump()


[Note : The thread dump will be generated in Thread_Dump_AdminServer.txt.]

Option 5) From a command line or shell, a thread dump can be generated via the following command (deprecated from WLS 9.0):
 
setDomain.cmd or setDomain.sh depending on the OS

java weblogic.Admin <url>:<port> -username <username> -password <password> THREAD_DUMP

[Note : The thread dump will be generated in the defined server stdout.]

Option 6) From the WLS Administration Console, a thread dump can be created by navigating to

Server -> <server_name> -> Monitoring -> Dump threads stack.

This method could lead to truncated or incomplete thread dumps.

Option 7) From the JRockit command line:

jrcmd <pid> print_threads

All are the methods or ways to generate thread dump in weblogic. We have several tools to analyse those tools.

Best WebLogic (JVM ) Thread Dump analyzer are:
  • Samurai
  • Java TDA
  • Thread Dump Viewer
  • Eclipse lock analyzer plugin
Hope it will help you in your day to day activities. Feel free to write me on middlewaresolution1@gmail.com.

Enjoy Working with middleware technologies.

Regards,
Ajinkya Vichare
Ajinkya-vichare@blogspot.com





3 comments:

  1. Good Post.. very useful.

    Thanks,
    www.wikiconsole.com

    ReplyDelete
  2. Hi Ajinkya,

    I have executed below command in my machine.

    SetDomainEnv.cmd
    java weblogic.WLST connect("weblogic","welcome1","t3://127.0.0.1:7001") threadDump()

    after running the above command I am getting the below error:-

    D:\Oracle\Middleware\user_projects\domains\base_domain\bin>setDomainEnv.cmd
    D:\Oracle\Middleware\user_projects\domains\base_domain>java weblogic.WLST connec
    t("weblogic","welcome1","t3://127.0.0.1:7001") threadDump()

    Initializing WebLogic Scripting Tool (WLST) ...

    Welcome to WebLogic Server Administration Scripting Shell

    Type help() for help on available commands

    Problem invoking WLST - java.io.FileNotFoundException: D:\Oracle\Middleware\user
    _projects\domains\base_domain\connect(weblogic,welcome1,t3:\127.0.0.1:7001) (The
    filename, directory name, or volume label syntax is incorrect)

    ReplyDelete
  3. Did you know that you can generate dollars by locking special areas of your blog / site?
    Simply join AdWork Media and implement their content locking plugin.

    ReplyDelete