tomcat停止了但是进程却未停止

1 篇文章 0 订阅
1 篇文章 0 订阅

tomcat停止了,只是停止了容器,可能还有java线程没停止,导致tomcat进程还在

 

  1. 拿到tomcat进程pid

ps -ef|grep tomcat   得到pid 31057

 

 

  1. 查看java进程,到底后台还在执行什么

jstack -F 31057 >> run.log

主要观察几种状态:

死锁,Deadlock(重点关注)

执行中,Runnable   

等待资源,Waiting on condition(重点关注)

等待获取监视器,Waiting on monitor entry(重点关注)

暂停,Suspended

对象等待中,Object.wait() 或 TIMED_WAITING

阻塞,Blocked(重点关注)  

停止,Parked

 

#50条    Ehcache缓存 停止后还在大量增加
Thread 26792: (state = BLOCKED)
 - java.lang.Thread.sleep(long) @bci=0 (Compiled frame; information may be imprecise)
 - net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThreadMain() @bci=8, line=108 (Compiled frame)
 - net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.access$0(net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator) @bci=1, line=103 (Interpreted frame)
 - net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread.run() @bci=4, line=376 (Interpreted frame)

 #41条 Ehcache缓存
 Thread 26793: (state = BLOCKED)
 - java.lang.Thread.sleep(long) @bci=0 (Compiled frame; information may be imprecise)
 - net.sf.ehcache.store.DiskStore.spoolAndExpiryThreadMain() @bci=20, line=669 (Compiled frame)
 - net.sf.ehcache.store.DiskStore.access$2(net.sf.ehcache.store.DiskStore) @bci=1, line=662 (Interpreted frame)
 - net.sf.ehcache.store.DiskStore$SpoolAndExpiryThread.run() @bci=4, line=1170 (Interpreted frame)
 

通过分析日志发现大量的Ehcache缓存在阻塞,怀疑可能是Ehcache没停导致tomcat的进程一直都在

PS : 在实际运行中,往往一次 dump的信息,还不足以确认问题。建议产生三次 dump信息,如果每次 dump都指向同一个问题,我们才确定问题的典型性。也就是多进行几次线程快照,观察变化,查看问题所在。

 

  1. 查看项目,发现项目有使用到ehcache, 但是没配置停止时释放ehcache资源,配置上后,再停止tomcat时,后台没有进程

web.xml

<!-- 释放ehcache资源 -->

<listener>    <listener-class>net.sf.ehcache.constructs.web.ShutdownListener</listener-class>

</listener>

<!--distributable /-->

 

欢迎参观我的个人网站

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值