报错信息:

java.lang.Object.wait(Native Method)

java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)

com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)

每次出现这个报错都会导致tomcat应用服务器停机,加了下面的java代码后就再也没有停过了。

解决办法:

编写Java代码

package cn.listener;

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();
}
}
}
@WebListener,这个注解相当于在web.xml配置如下内容
  <listener>
<listener-class>cn.listener.ContextFinalizer</listener-class>
</listener>
 

解决方案可以参考如下网址:https://stackoverflow.com/questions/25699985/the-web-application-appears-to-have-started-a-thread-named-abandoned-connect

当然还有就是我再参考这个解决方案的时候,发现mysql-connection如果版本过低会导致上述列出的Java代码报错,通过提高mysql-connection.java的版本即可解决该问题

tomcat服务器宕机解决方案的更多相关文章

  1. nginx+keepalived高可用服务器宕机解决方案

    http://blog.51cto.com/gdutcxh/2109841 https://blog.csdn.net/winsonyuan/article/details/52784988

  2. 【MySQL】MySQL主从库配置和主库宕机解决方案

    1.转载:https://blog.csdn.net/zfl589778/article/details/51441719/ 2.效果:亲测有效,数据写入成功. 3.主机宕机后,如果不是长时间宕机,且 ...

  3. 服务器宕机,mysql无法启动,job for mysql.service failed because the process exited with error code,数据库备份与恢复

    [问题现象] 服务器在运行过程中,因人为意外导致电源被拔,服务器宕机,mysql重启不成功,报错如下 根据提示,输入systemctl status mysql.service和journalctl ...

  4. Nginx解决服务器宕机问题

    1.Nginx解决服务器宕机问题,Nginx配置服务器宕机策略,如果服务器宕机,会找下一台机器进行访问 配置nginx.cfg配置文件,在映射拦截地址中加入代理地址响应方案 location / { ...

  5. PHP载入GIF图像造成服务器宕机(CVE-2018-5711)的漏洞复现

    参考链接: http://www.freebuf.com/vuls/161262.html 今日看新漏洞发现一个UC编辑部的标题,CVE-2018-5711:一张GIF图片就能让服务器宕机的PHP漏洞 ...

  6. 远离服务器宕机,腾讯WeTest正式推出服务器深度性能测试服务

    WeTest 导读 随着城市发展趋向智慧化,不仅移动互联网应用正迅速融入出行.金融.医疗.娱乐等传统行业,跟随移动互联网成长起来的,还有用户对应用使用与消费的理性意识. 而在用户不断增加的同时,如何避 ...

  7. linux服务器宕机分析/性能瓶颈分析

    linux服务器宕机分析/性能瓶颈分析   服务器宕机原因很多,资源不足.应用.硬件.系统内核bug等,以下一个小例子 服务器宕机了,首先得知道服务器宕机的时间点,然后分析日志查找原因 1.last ...

  8. nginx解决服务器宕机、解决跨域问题、配置防盗链、防止DDOS流量攻击

    解决服务器宕机 配置nginx.cfg配置文件,在映射拦截地址中加入代理地址响应方案 location / { proxy_connect_timeout 1; proxy_send_timeout ...

  9. Nginx配置服务器宕机策略

    Nginx解决服务器宕机问题,Nginx配置服务器宕机策略,如果服务器宕机,会找下一台机器进行访问        配置nginx.cfg配置文件,在映射拦截地址中加入代理地址响应方案 location ...

随机推荐

  1. Python import搜索的路径顺序

    在程序中导入时,如下顺序 1.Python 标准库模块2.Python 第三方模块3.应用程序自定义模块   import的搜索顺序: 首先判断这个module是不是built-in即内建模块,如果是 ...

  2. 用pymysql操作数据库

    import pymysql # 打开数据库连接 connection = pymysql.connect(host='127.0.0.1', user='root', passwd=', db='s ...

  3. Markdown预览功能不可用解决方案

    初学者在使用Markdown时也许会遇到这个问题 原因是电脑缺少一个组件,解决方案很简单,安装上就好了,以下是链接 http://markdownpad.com/download/awesomium_ ...

  4. 【代码笔记】iOS-cell自动变化大小

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  5. OAuth2学习笔记

    参考:https://aaronparecki.com/oauth-2-simplified/ 1.角色定义 应用程序(客户) 需要获取用户的账号信息,获得相关权限. API服务器 资源服务器就是AP ...

  6. 日历视图(CalendarView)

    日历视图(Calendarview) 常用属性: android:selectedWeekBackgroundColor(设置被选中周的背景颜色) android:showWeekNumber(设置是 ...

  7. 观察者模式 - Java 实现1(使用JDK内置的Observer模式)

    使用JDK内置的观察者模式 1. 可观察者(主题) 被观察的主题继承 Observable 对象, 使用该对象的调用 notifyObservers() 或 notifyObservers(arg) ...

  8. Latex 数学公式使用入门

    Latex 数学公式使用示例 Latex 数学公式命令中,数学符号都使用反斜杠(backslash, '\')转义英文缩略词 , 一些简单的数学符号命令: 其使用大括号(curly braces, ' ...

  9. ExpressRoute 连接模型

    可通过以下三种不同方式,创建本地网络和 Azure 云之间的连接:CloudExchange 归置.点对点以太网连接和任意位置之间的 (IPVPN) 连接.连接服务提供商可以提供一个或多个连接模型.可 ...

  10. Oracle EBS AR 更新客户配置文件

    DECLARE l_rec_profile_t hz_customer_profile_v2pub.customer_profile_rec_type; l_rec_profile hz_custom ...