Christopher Schultz wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrea,

Andrea Di Muro wrote:
| Tomcat is running on a Linux Server, what is the exact command to take the
| thread dump?
| kill -s QUIT tomcat_pid is right?

Yes. The thread dump will be printed on stdout, and probably go into
catalina.out.

| By using this command will Tomcat shut down or just print the threa
dump on
| the standard output?

Only the thread dump -- Tomcat will not shutdown.

| And how can I interpret the output to see which page is causing the
| problem?

A thread dump is like a stack trace, except that it performs a stack
trace on /all/ live threads. It will tell you what each thread is doing.

If you see a few threads that are running methods like _jsp_service,
then those threads are running JSPs. The name of the JSP should be
evident from the class and method name printed in the trace for that
particular thread.

You could observe several thread dumps to see if one particular thread
(or several) are always executing the same method. If so, that JSP is
probably the one that is hanging.


Another (perhaps Linux-specific?) way to get some information is to run
"ps -fLp 12345" (where 12345 should be the PID of your Tomcat process).
This will show one line for each thread in the Tomcat process, and also
will show the amount of CPU time used by each thread. If you run this
a couple of times, you should be able to pick up threads with significant
increase in the used CPU time. These can then be correlated with the
thread dump. F.ex. in my "toy" machine, the thread taking the most of
CPU time is:
tomcat 7035 1 7870 0 40 Feb13 ? 01:08:37 /usr/lib/jvm/java/bin
... where 7035 is the process id of Tomcat, and 7870 is the thread id.

The thread dump then tells what that thread is running - however, the
thread dump lists threads by hexadecimal id, and the above is decimal,
so a conversion is needed: 7870=0x1ebe . Now to look for that 1ebe
in the thread dump:

"ContainerBackgroundProcessor[StandardEngine[Catalina]]" daemon prio=1 tid=0x08366728 nid=0x1ebe waiting on condition [0xb135c000..0xb135cfa0]
       at java.lang.Thread.sleep(Native Method)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1597)
       at java.lang.Thread.run(Thread.java:595)

.... so, on this machine (a toy, as I said), the thread with most accumulated
CPU usage has been ContainerBackgroundProcessor - which was sleeping
at the time of this thread dump. For active request processing threads the
dump will differ a lot from the above, and will tell in which class/method
the thread is executing.
--
..Juha

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to