tomcat运行一段时间之后自动挂掉,暂没找到原因

苏子莫1950679341 2015-12-11 02:44:35
项目是springMvc+mybatis,其中用到了mongodb和redis,项目运行一段时间之后报出如下信息自动挂掉。
11-Dec-2015 12:58:14.479 INFO [Thread-12] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-80"]
11-Dec-2015 12:58:14.480 INFO [Thread-12] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
11-Dec-2015 12:58:14.481 INFO [Thread-12] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
12:58:14.531 [localhost-startStop-2] WARN o.s.b.f.s.DisposableBeanAdapter - Invocation of destroy method 'close' failed on bean with name 'sqlSessionTemplate': java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession

11-Dec-2015 12:58:14.539 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
11-Dec-2015 12:58:14.540 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [MongoCleaner586264031] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Thread.sleep(Native Method)
com.mongodb.Mongo$CursorCleanerThread.run(Mongo.java:770)
11-Dec-2015 12:58:14.540 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
com.mysql.jdbc.NonRegisteringDriver$1.run(NonRegisteringDriver.java:93)
11-Dec-2015 12:58:14.541 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)
11-Dec-2015 12:58:14.541 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.542 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.542 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-3] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.543 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.543 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-5] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.544 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-6] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.544 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-7] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.545 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-8] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.545 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-9] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.546 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [DefaultQuartzScheduler_Worker-10] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
11-Dec-2015 12:58:14.547 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [com.mongodb.DBTCPConnector$1] (value [com.mongodb.DBTCPConnector$1@43dc2744]) and a value of type [com.mongodb.DBTCPConnector.MyPort] (value [com.mongodb.DBTCPConnector$MyPort@2a96042a]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
11-Dec-2015 12:58:14.547 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [com.mongodb.DBTCPConnector$1] (value [com.mongodb.DBTCPConnector$1@43dc2744]) and a value of type [com.mongodb.DBTCPConnector.MyPort] (value [com.mongodb.DBTCPConnector$MyPort@5eeb773d]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
11-Dec-2015 12:58:14.548 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [com.mongodb.DBTCPConnector$1] (value [com.mongodb.DBTCPConnector$1@43dc2744]) and a value of type [com.mongodb.DBTCPConnector.MyPort] (value [com.mongodb.DBTCPConnector$MyPort@34e1767a]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
11-Dec-2015 12:58:14.548 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [com.mongodb.DBTCPConnector$1] (value [com.mongodb.DBTCPConnector$1@43dc2744]) and a value of type [com.mongodb.DBTCPConnector.MyPort] (value [com.mongodb.DBTCPConnector$MyPort@3e295eb5]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
11-Dec-2015 12:58:14.548 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [com.mongodb.DBTCPConnector$1] (value [com.mongodb.DBTCPConnector$1@43dc2744]) and a value of type [com.mongodb.DBTCPConnector.MyPort] (value [com.mongodb.DBTCPConnector$MyPort@e08dcf5]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
项目是springMvc+mybatis,其中用到了mongodb和redis,项目运行一段时间之后报出如上信息自动挂掉。
...全文
10004 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
放风筝的蚂蚁 2017-11-24
  • 打赏
  • 举报
回复
根据这个日志可以看出是由于ThreadLocal维护的mongodb链接对象没有释放导致的内存泄漏,为什么会没有释放呢?因为因为每一个线程维护了一个类型为ThreadLocal.ThreadLocalMap的threadLocals变量用来维护当前线程ThreadLocal设置的对象,以ThreadLocal实例为key,以ThreadLocal中设置的对象为value,而该ThreadLocal实例在put进threadLocals时变成了弱引用,弱引用在gc的时候肯定会被释放,而以ThreadLocal实例为key对应的value是强引用,如果当前线程没有退出,比如使用了线程池,则在gc的时候不会释放该强引用,则threadLocals中会存在<null,Value>的键值对,如果线程很多,则会造成内存泄露,原理是这样
lk311377 2017-11-22
  • 打赏
  • 举报
回复
21-Nov-2017 19:08:38.169 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [cmmp] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 21-Nov-2017 19:08:38.170 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [cmmp] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143) com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43) 21-Nov-2017 19:08:38.170 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [cmmp] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.util.TimerThread.mainLoop(Timer.java:552) java.util.TimerThread.run(Timer.java:505) 也是tomcat过一段时间就自动停止了 能找到的方法都用了 都没用 困扰我好长时间了
chenbo321chenbo 2016-11-17
  • 打赏
  • 举报
回复
楼主解决了么
  • 打赏
  • 举报
回复
引用 10 楼 xiesq5112 的回复:
[quote=引用 8 楼 SuZiMo1950679341 的回复:] [quote=引用 7 楼 xiesq5112 的回复:] 结贴就好,这才是最实在的
还是不行,重启tomcat之后运行一段时间之后tomcat还是自动挂掉,我现在只能每次部署完之后都的重启操作系统才行。[/quote] 不知道了, 但我想没必要重启操作系统吧[/quote] 我重启操作系统之后,项目就可以一直运行下去,没有之前所说的tomcat自动重启的现象。
心随自在飞 2015-12-17
  • 打赏
  • 举报
回复
引用 8 楼 SuZiMo1950679341 的回复:
[quote=引用 7 楼 xiesq5112 的回复:] 结贴就好,这才是最实在的
还是不行,重启tomcat之后运行一段时间之后tomcat还是自动挂掉,我现在只能每次部署完之后都的重启操作系统才行。[/quote] 不知道了, 但我想没必要重启操作系统吧
  • 打赏
  • 举报
回复
引用 7 楼 xiesq5112 的回复:
结贴就好,这才是最实在的
我怀疑我关掉tomcat之后,某些链接还没有释放,再次重启tomcat之后运行一段时间之后,莫名其妙的tomcat就挂掉。
  • 打赏
  • 举报
回复
引用 7 楼 xiesq5112 的回复:
结贴就好,这才是最实在的
还是不行,重启tomcat之后运行一段时间之后tomcat还是自动挂掉,我现在只能每次部署完之后都的重启操作系统才行。
心随自在飞 2015-12-12
  • 打赏
  • 举报
回复
结贴就好,这才是最实在的
  • 打赏
  • 举报
回复
引用 5 楼 xiesq5112 的回复:
<property name="maxActive" value="100"></property> <property name="maxIdle" value="30"></property> <property name="maxWait" value="30000"></property> <property name="defaultAutoCommit" value="true"></property> 配置改一下!
但愿能用,多谢啦
心随自在飞 2015-12-11
  • 打赏
  • 举报
回复
<property name="maxActive" value="100"></property> <property name="maxIdle" value="30"></property> <property name="maxWait" value="30000"></property> <property name="defaultAutoCommit" value="true"></property> 配置改一下!
  • 打赏
  • 举报
回复
引用 3 楼 xiesq5112 的回复:
的确是与数据连接相关。 把代码配置贴出来,看看你DataSource的相关配置。
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 --> <property name="typeAliasesPackage" value="com.hukan.hkhx.entity" /> <!-- 显式指定Mapper文件位置 --> <property name="mapperLocations" value="classpath:/mybatis/*/*Mapper.xml" /> <property name="configurationProperties"> <props> <prop key="cacheEnabled">true</prop> <!-- 对于批量更新操作缓存SQL以提高性能 --> <prop key="defaultExecutorType">BATCH</prop> </props> </property> </bean> <!-- 配置SqlSessionTemplate --> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory" /> </bean> <!-- 数据源配置, 使用Tomcat JDBC连接池 --> <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"> <!-- Connection Info --> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- Connection Pooling Info --> <property name="maxActive" value="${jdbc.pool.maxActive}" /> <property name="maxIdle" value="${jdbc.pool.maxIdle}" /> <property name="minIdle" value="0" /> <property name="defaultAutoCommit" value="false" /> </bean> jdbc.driver=net.sf.log4jdbc.DriverSpy jdbc.url=jdbc:log4jdbc:mysql:///test?useUnicode=true&characterEncoding=utf-8 jdbc.username=uiuiu jdbc.password=123456 jdbc.pool.maxIdle=10 jdbc.pool.maxActive=1000
心随自在飞 2015-12-11
  • 打赏
  • 举报
回复
的确是与数据连接相关。 把代码配置贴出来,看看你DataSource的相关配置。
kl172 2015-12-11
  • 打赏
  • 举报
回复
看上去像是由数据库连接引起的内存溢出。
  • 打赏
  • 举报
回复
会不会是tomcat内存太小导致项目自动挂了?我以前遇到过一次这样的情况 调整tomcat内存大小

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧