Tuesday, April 2, 2019

Different ways to take thread dumps in WebLogic Server

Purpose

This article provides information about different ways on taking java thread dumps in a 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...

Different ways to take thread dumps in WebLogic Server

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.

  1. Use operating system commands to get the thread dumps when WLS starts up from a command-line script:
    • On Windows OSes, 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 the command 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.
  2. Using beasvc (up to WLS 10.3.5 included):
    beasvc -dump -svcname:<service_name>
    • service_name is the Windows service that is running the server instance (e.g. mydomain_myserver)
  3. Using wlsvc (from 10.3.6/12.1.1):
    wlsvc -dump -svcname:<service_name>
  4. Using weblogic.WLST:
    setDomainEnv.cmd or setDomainEnv.sh depending on the OS
    java weblogic.WLST
    connect("<username>","<password>","t3://<url>:<port>")
    threadDump()
    The thread dump will be generated in Thread_Dump_AdminServer.txt. Note 1274713.1 addresses WLST thread dumps in more detail with examples on how to define sleep time between each dump and number of dumps to take.
  5. From a command line or shell, a thread dump can be generated via the following command (deprecated from WLS 9.0, and is only available till WLS release 12.1.3. The weblogic.Admin utility is no longer shipped from 12.2.1.x onwards):
    setDomainEnv.cmd or setDomainEnv.sh depending on the OS
    java weblogic.Admin -url <url>:<port> -username <username> -password <password> THREAD_DUMP
    Example: java weblogic.Admin -url t3://localhost:7001 -username weblogic -password welcome1 THREAD_DUMP (The thread dump will be generated in the defined server stdout).
  6. From the WLS Administration Console, a thread dump can be created by navigating to Servers -> <server_name> -> Monitoring -> Threads -> Dump threads stack. This method could lead to truncated or incomplete thread dumps.
  7. From the Services Administration Tools when WLS runs as a Windows Service, see Note 1348645.1
  8. Java VisualVM can also be used to take thread dumps while applications are running, see http://docs.oracle.com/javase/6/docs/technotes/guides/visualvm/applications_local.html for more details
  9. With jstack
    jstack <pid> or jstack -l <pid> to print additional information about locks
  10. From the JRockit command line:
    jrcmd <pid> print_threads
  11. From Java Mission Control with JDK 7:
    jcmd <pid> Thread.print 


No comments:

Post a Comment

Database Options/Management Packs Usage Reporting for Oracle Databases 11.2 and later (Doc ID 1317265.1)

  Database Options/Management Packs Usage Report You can determine whether an option is currently in use in a database by running options_pa...