Thread dump is essential for Java application troubleshooting. If you are working on performance related, memory leakage, debugging, etc. then you will often be asked to take thread and heap dump.
You may take the dump manually but if you would like to do it automatically then here is how you can do it.The following demonstration is based on
The following demonstration is based on WebSphere 9, but the procedure would be similar to other WAS version.
Taking Thread Dump When JVM Stop
There might be a scenario where you would like to take the thread dump whenever JVM stop. This will be useful when you are not sure whom or how JVM is getting stopped.
To configure this;
- Login to WebSphere Administrative Console
- Navigate to Servers >> Server Types >> WebSphere application servers
- Go inside the JVM and expand “Java and Process Management” under Server Infrastructure
- Click Process definition
- Click “Java Virtual Machine” under Additional Properties >> Custom properties
- Click New and enter Name as
- Value as true
- Click OK
- Review and Save the configuration
Now, heap dump will be generated whenever JVM stop.
I stopped the JVM and could see the following javacore file on WAS server under profile path.
-rw-r--r--. 1 root root 3179348 Nov 28 22:49 javacore.20161128.224916.4926.0001.txt -rw-r--r--. 1 root root 3124208 Nov 28 22:49 javacore.20161128.224924.4926.0002.txt
Taking Thread Dump When Hung
If you are having hung thread issue, and currently you take the dump manually, then you can automate this.
By doing basic configuration, WebSphere will generate the dump whenever a thread is hung for configured timed.
- Login to WAS Console and go inside respective JVM
- Expand “Administration” under Server Infrastructure and click Custom Properties
- Add the following three properties
com.ibm.websphere.threadmonitor.threshold – Generate dump when a thread is hung for configured time. Value is in seconds.
com.ibm.websphere.threadmonitor.interval – How frequently thread monitor should check for the hung threads. The value in seconds.
com.ibm.websphere.threadmonitor.dump.java – Generate dump when detected. Value is true.
Above configuration will generate dump whenever a thread is hung for 600 seconds, and WebSphere will monitor the thread every 300 seconds.
Once you have the dump, you can analyze and fix the application issue. I hope this helps.
More great readings on WebSphere
What is Thread Dump and How to Analyze them?Asad Ali on June 29, 2020
IBM WebSphere Application Server Beginner’s GuideChandan Kumar on June 9, 2022
How to Monitor IBM WebSphere using Application Manager?Chandan Kumar on June 9, 2022
How to Use Nginx with WebSphere Application Server?Chandan Kumar on June 9, 2022
How to Create Cluster in IBM WebSphere ND?Chandan Kumar on June 9, 2022
What’s New in WebSphere MQ 9 & Installation GuideChandan Kumar on June 10, 2022
Join Geekflare Newsletter
Every week we share trending articles and tools in our newsletter. More than 10,000 people enjoy reading, and you will love it too.