最近在项目中,突发了一个情况,就是服务器在跑了一段时间之后,总是会莫名其妙的挂掉,初始的时候认为是服务器原因,也没有多加理会,直接重启了服务,可是当这个情况出现了两三次之后,感觉不对,还是得解决一下,这是个问题。

异常信息:

31-May-2018 09:53:48.523 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [xw-wyyx-school] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
31-May-2018 09:53:48.524 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [xw-wyyx-school] 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.
31-May-2018 09:53:48.530 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [xw-wyyx-school] 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:40)
31-May-2018 09:53:48.531 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [xw-wyyx-school] 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)
31-May-2018 09:53:48.617 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-9080"]
31-May-2018 09:53:48.627 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-9009"]
31-May-2018 09:53:48.635 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-9080"]
31-May-2018 09:53:48.636 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-9009"]

细看一下,原来是mysql驱动,线程回收不及时,导致tomcat守护线程报错。

解决方案:

package com.ds.utils;import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Enumeration;import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;import com.mysql.jdbc.AbandonedConnectionCleanupThread;@WebListener
public class ContextFinalizer implements ServletContextListener {public void contextInitialized(ServletContextEvent sce) {}public void contextDestroyed(ServletContextEvent sce) {Enumeration<Driver> drivers = DriverManager.getDrivers();Driver d = null;while (drivers.hasMoreElements()) {try {d = drivers.nextElement();DriverManager.deregisterDriver(d);System.out.println(String.format("ContextFinalizer:Driver %s deregistered", d));} catch (SQLException ex) {System.out.println(String.format("ContextFinalizer:Error deregistering driver %s", d) + ":" + ex);}}try {AbandonedConnectionCleanupThread.shutdown();} catch (InterruptedException e) {System.out.println("ContextFinalizer:SEVERE problem cleaning up: " + e.getMessage());e.printStackTrace();}}
}

The web application [] appears to have started a thread named [thread-0]相关推荐

  1. 严重: The web application [] appears to have started a thread named [Thread-

    http://www.myexception.cn/h/988782.html 1,获取dump 2,从dump找到正在运行的线程所属class 3,在myeclise 开启debug模式,给正在运行 ...

  2. 异常:“严重: The web application [] appears to have started a thread named [Thread-”

     严重: The web application [] appears to have started a thread named [TestScheduler_Worker-1] but ha ...

  3. The web application [] appears to have started a thread named [Thread-

    在eclipse上部署web项目到tomcat启动时出现了"The web application [] appears to have started a thread named [Th ...

  4. WebappClassLoaderBase | The web application [ROOT] appears to have started a thread named [HikariPo

    原文链接 linux(RHEL8)中使用root启动java程序(使用springboot 框架)时可以正常的访问,而当使用非root用户启动springboot 的java 程序时,遇到以下错误: ...

  5. tomcat 启动异常 The web application [ROOT] registered the JDBC driver [xxx] but failed to unregister it

    tomcat启动的时候出现如下异常: 22-Feb-2021 20:25:30.697 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina ...

  6. ModSecurity web application firewall (WAF) Research - .Little Hann

    转载地址:http://bluereader.org/article/97681813 catalog 引言 OWASP ModSecurity Core Rule Set (CRS) Project ...

  7. ModSecurity web application firewall (WAF) Research

    catalog 0. 引言1. OWASP ModSecurity Core Rule Set (CRS) Project2. Installation mod_security forApache3 ...

  8. 微软压力测试工具 web application stress

    WEB服务器的压力测试工具~ 115808 2009年8月1日 lbimba 铜牌会员 这里给广大的煤油推荐一个web网站压力测试工具.它可以用来模拟多个用户操作网站,在程序投入运行时,可以用它来进行 ...

  9. Unable to complete the scan for annotations for web application

    2019独角兽企业重金招聘Python工程师标准>>> Unable to complete the scan for annotations for web application ...

最新文章

  1. 5如何将表格的一行数据清空_微信公众号推文中如何自定义添加表格?
  2. dev 获取gridview没有rows属性_虚拟黑群晖不直通也可以获取到SMART?
  3. 《R语言与数据挖掘最佳实践和经典案例》—— 第3章 数 据 探 索
  4. 关于XML文档操作类
  5. 阵列卡直通模式和raid模式_DNF:希洛克Raid攻坚流程攻略
  6. 被利用达数百万次、瞄准 Linux 系统的 Top 15漏洞
  7. python调试利器pysnooper
  8. 移动磁盘修复、格式化【微PE】
  9. 不买服务器,使用网络通免费发布网站到外网
  10. 有些事现在不做,一辈子都不会做了
  11. 【懒懒的Python学习笔记一】
  12. Python统计英文、中文、数字、空格等字符数
  13. Java 基于WEB的农产品销售管理系统源码+数据库+论文文档+项目辅导视频
  14. 支付宝支付 62009
  15. java tif合成_JAI 多图片合成TIF格式
  16. ViewFlipper的用法
  17. 鼠标背景带光圈突出显示
  18. LinearLayout布局添加下划线
  19. Game Engine Architecture by Jason Gregory:1.6 实时游戏引擎架构
  20. VMware设置共享文件夹之后Linux中看不到怎么办?

热门文章

  1. jquery实现图片上传
  2. 产品负责人(Product Owner)的主要职责和技能
  3. wav,flac,mp3,ogg等的区别
  4. [转]C语言图形编程(三) -绘图函数②
  5. c语言printf双精度还需要lf,C语言中printf区分双精度和单精度吗?为什么用lf输出不了双精度浮点数?...
  6. 猫眼电影字体反爬-自动处理字体加密
  7. linux 修改hosts
  8. python基础-廖雪峰
  9. 高数笔记(三):函数的连续性和间断性,闭区间上连续函数的性质
  10. datasets: mnist