Is there away to take a thread dump from Tomcat? I would like to monitor the threads running in Tomcat at a certain point in time.
Note: I was doing that on Web logic but i don't know how it can be done on Tomcat.
Is there away to take a thread dump from Tomcat? I would like to monitor the threads running in Tomcat at a certain point in time.
Note: I was doing that on Web logic but i don't know how it can be done on Tomcat.
add java melody to your server https://code.google.com/p/javamelody/
it give you a lot of info including threads in runtime
There is a simple way to monitor tomcat threads and do a dump. Start tomcat with the folowing java options :
-Dcom.sun.management.jmxremote.port=<some free port>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
After the tomcat is restarted you can simply start jconsole (part of jdk) or visualvm and create a new jmx connection to the port you have chosen above.
In both tools you also have an option to take a dump ;)
!!!But do that only in closed/secured environment - since there is no authentication set.!!!
The following steps should help you get the current Java threads running and analyze them:
root@localhost:~# sudo -u $TOMCAT_USER $JAVA_HOME/bin/jstack -J-d64 -l $(ps aux | grep '[c]atalina' | awk '{print $2}') > ~/threads.log
Note: Replace $JAVA_HOME
with your path to your current JDK, $TOMCAT_USER
with the user running Tomcat; if you pass the wrong user or even using root you will get an error like this:
3047: well-known file is not secure
If you use Linux, you can send a kill -3 [pid of your tomcat] and it will dump all current threads in the catalina.out.