Login

Language :
Titletomcat thread dump
tomcat thread dump
Writer이지섭Write DateApr 29 2018Modify DateAug 9 2024View Count3385

This is guide to dump Tomcat thread.

 

Basically, under the Tomcat home, under the webapps,

there must be manager directory.

This directory is provided basically by Tomcat.

 

The object is

http://localhost/manager/text/threaddump

Like above, in web browser view the thread dump.

 

1)  Process 1.

  Modify the below xml file.

  TOMCAT_HOME/webapps/manager/META-INF/context.xml

 

<context privileged="true" antiresourcelocking="false">
  <valve allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" classname="org.apache.catalina.valves.RemoteAddrValve">
  <manager sessionattributevalueclassnamefilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap">
</manager>

 →

<context privileged="true" antiresourcelocking="false">
  <valve allow="^.*$" classname="org.apache.catalina.valves.RemoteAddrValve">
  <manager sessionattributevalueclassnamefilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap">
</manager>

  This make all IPs accessible to dump thread. 

  Before this only 127.0.0.1, localhost has access to dump thread.

 

2)  Process 2.

  Modify below xml file.

  TOMCAT_HOME/conf/tomcat-users.xml

 

  Add below two line to the tomcat-users tag in this xml file.

<role rolename="manager-script"/>
<user username="tomcat10" password="password Input" roles="manager-script"/>

 

  http://localhost/manager/text/threaddump

  The dump program runs as manager-script provileges.

  So add the role and user.

 

 
Repeatedly,
 
  TOMCAT_HOME/webapps/manager/META-INF/context.xml   : configure accessible IPs

  TOMCAT_HOME/conf/tomcat-users.xml   : configure previleges
 
After above two configuration,

 

http://localhost/manager/text/threaddump

또는

http://localhost:8080/manager/text/threaddump
 
By call a URL like above we can view Tomcat thread dump.
 
To view the content we must input ID and Password,
 
this is in the tomcat-users.xml file, above 2).
 
 

The dump content like below.

OK - JVM thread dump
2018-04-29 18:02:06.791
Full thread dump Java HotSpot(TM) 64-Bit Server VM (9.0.1+11 mixed mode):

"Abandoned connection cleanup thread" Id=45 cpu=603854 ns usr=0 ns blocked 1 for -1 ms waited 3 for -1 ms
   java.lang.Thread.State: TIMED_WAITING
	locks java.util.concurrent.ThreadPoolExecutor$Worker@ddd6377
	at java.base@9.0.1/java.lang.Object.wait(Native Method)
	- waiting on (a java.lang.ref.ReferenceQueue$Lock@4fa28c62)
	at java.base@9.0.1/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
	at com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:64)
	at java.base@9.0.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.base@9.0.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.base@9.0.1/java.lang.Thread.run(Thread.java:844)

"ajp-nio-8009-AsyncTimeout" Id=43 cpu=264727 ns usr=0 ns blocked 0 for -1 ms waited 8 for -1 ms
   java.lang.Thread.State: TIMED_WAITING
	at java.base@9.0.1/java.lang.Thread.sleep(Native Method)
	at org.apache.coyote.AbstractProtocol$AsyncTimeout.run(AbstractProtocol.java:1133)
	at java.base@9.0.1/java.lang.Thread.run(Thread.java:844)

"ajp-nio-8009-Acceptor-0" Id=42 cpu=4483464 ns usr=0 ns blocked 0 for -1 ms waited 0 for -1 ms (running in native)
   java.lang.Thread.State: RUNNABLE
	at java.base@9.0.1/sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
	at java.base@9.0.1/sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:424)
	at java.base@9.0.1/sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:252)
	- locked (a java.lang.Object@7346f5be) index 2 frame java.base@9.0.1/sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:252)
	at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:455)
	at java.base@9.0.1/java.lang.Thread.run(Thread.java:844)

...
...
...

Comment

Name               Password 
Content
Check Password.

Please enter your password when registering your comment.