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 ...
随机推荐
- 使用css实现炫酷的横屏滚动效果
炫酷的横屏滚动效果css实现 DEMO: https://codepen.io/kobako/pen/BxVLLm 我们对滚动条都不陌生.平时浏览的网页,进度条通常是垂直方向的,内容从上往下排列.但是 ...
- mysql索引类型normal,unique,full text的区别
normal:表示普通索引 unique:表示唯一的,不允许重复的索引,如果该字段信息保证不会重复例如身份证号用作索引时,可设置为unique full textl: 表示 全文搜索的索引. FULL ...
- linux系统下开启一个简单的web服务
linux 下开启一个简单的web服务: 首先需要linux下安装nodejs 然后创建一个test.js: vi test.js var http =require("http&quo ...
- Django基础十之Form和ModelForm组件
一 Form介绍 我们之前在HTML页面中利用form表单向后端提交数据时,都会写一些获取用户输入的标签并且用form标签把它们包起来. 与此同时我们在好多场景下都需要对用户的输入做校验,比如校验用户 ...
- MOTT介绍(2)window安装MQTT服务器和client
MQTT目录: MQTT简单介绍 window安装MQTT服务器和client java模拟MQTT的发布,订阅 window安装MQTT服务器,我这里下载了一个apache-apollo-1.7.1 ...
- javascript 关于new()继承的笔记
近期的一些学习总结,如有错误不严谨地方,希望指正! 使用new操作符会有如下操作: 1.创建一个对象temp = {}, 2. temp.__proto__ = A.prototype, 3. A.c ...
- 传递命令行参数示例代码 (C 和 Python)
C语言 在 C 语言中, 使用 main 函数的输入参数 argc 和 argv 传入命令行参数. argc 为 int 类型, 表示传入命令行参数的个数 (argument count); argv ...
- Oracle EBS 查询用户职责
select b.user_name UserID, b.description User_Name, f.RESPONSIBILITY_NAME RESPONSIBILITY from FND_US ...
- 判断js对象类型
javascript中检测对象的类型的运算符有:typeof.constructor.instanceof.prototype. 1.typeof typeof是一个一元运算符,返回结果是一个说明运算 ...
- [翻译] IDMPhotoBrowser
IDMPhotoBrowser IDMPhotoBrowser is a new implementation based on MWPhotoBrowser. IDMPhotoBrowser实现了图 ...