tomcat服务器宕机解决方案
报错信息:
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服务器宕机解决方案的更多相关文章
- nginx+keepalived高可用服务器宕机解决方案
http://blog.51cto.com/gdutcxh/2109841 https://blog.csdn.net/winsonyuan/article/details/52784988
- 【MySQL】MySQL主从库配置和主库宕机解决方案
1.转载:https://blog.csdn.net/zfl589778/article/details/51441719/ 2.效果:亲测有效,数据写入成功. 3.主机宕机后,如果不是长时间宕机,且 ...
- 服务器宕机,mysql无法启动,job for mysql.service failed because the process exited with error code,数据库备份与恢复
[问题现象] 服务器在运行过程中,因人为意外导致电源被拔,服务器宕机,mysql重启不成功,报错如下 根据提示,输入systemctl status mysql.service和journalctl ...
- Nginx解决服务器宕机问题
1.Nginx解决服务器宕机问题,Nginx配置服务器宕机策略,如果服务器宕机,会找下一台机器进行访问 配置nginx.cfg配置文件,在映射拦截地址中加入代理地址响应方案 location / { ...
- PHP载入GIF图像造成服务器宕机(CVE-2018-5711)的漏洞复现
参考链接: http://www.freebuf.com/vuls/161262.html 今日看新漏洞发现一个UC编辑部的标题,CVE-2018-5711:一张GIF图片就能让服务器宕机的PHP漏洞 ...
- 远离服务器宕机,腾讯WeTest正式推出服务器深度性能测试服务
WeTest 导读 随着城市发展趋向智慧化,不仅移动互联网应用正迅速融入出行.金融.医疗.娱乐等传统行业,跟随移动互联网成长起来的,还有用户对应用使用与消费的理性意识. 而在用户不断增加的同时,如何避 ...
- linux服务器宕机分析/性能瓶颈分析
linux服务器宕机分析/性能瓶颈分析 服务器宕机原因很多,资源不足.应用.硬件.系统内核bug等,以下一个小例子 服务器宕机了,首先得知道服务器宕机的时间点,然后分析日志查找原因 1.last ...
- nginx解决服务器宕机、解决跨域问题、配置防盗链、防止DDOS流量攻击
解决服务器宕机 配置nginx.cfg配置文件,在映射拦截地址中加入代理地址响应方案 location / { proxy_connect_timeout 1; proxy_send_timeout ...
- Nginx配置服务器宕机策略
Nginx解决服务器宕机问题,Nginx配置服务器宕机策略,如果服务器宕机,会找下一台机器进行访问 配置nginx.cfg配置文件,在映射拦截地址中加入代理地址响应方案 location ...
随机推荐
- CodeForces760A
A. Petr and a calendar time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- xamarin.android App在后台运行不退出
/// <summary> /// 重写按键事件 /// </summary> /// <param name="keyCode"></p ...
- 初级版python登录验证,上传下载文件加MD5文件校验
服务器端程序 import socket import json import struct import hashlib import os def md5_code(usr, pwd): ret ...
- 关于JqueryCheck选中获取数据
关于Jquery获取Check选中数据 首先还是得引用Jquery的包,然后新增3个CheckBox <div> <input type="checkbox" n ...
- gulp自动化打包及静态文件自动添加版本号
前端自动化打包发布已是一种常态,尤其在移动端,测试过程中静态资源的缓存是件很头疼的事情,有时候明明处理的bug测试还是存在,其实就是缓存惹的祸,手机不比pc浏览器,清理缓存还是有点麻烦的.所以自动化实 ...
- bzoj P3309 DZY Loves Math——solution
对于正整数n,定义f(n)为n所含质因子的最大幂指数.例如f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10007)=1, f(1)=0.给定正整数a,b,求: $$\sum_{i= ...
- 基于token的后台身份验证(转载)
几种常用的认证机制 HTTP Basic Auth HTTP Basic Auth简单点说明就是每次请求API时都提供用户的username和password,简言之,Basic Auth是配合RES ...
- JavaWEB SSH文件上传
一.提交表单的<form> method属性必须为post 并且添加enctype="multipart/form-data" 属性 前台: <td>上传 ...
- Eclipse Ctrl + H 搜索文件不覆盖已打开文件解决办法
1.windows------->preferences
- LeetCode 题解之Add Binary
1.题目描述 2.题目分析 使用string 的逆向指针,做二进制加法,注意进位问题就可以. 3.代码 string addBinary(string a, string b) { string::r ...