This is very likely to create a memory leak. Stack trace of thread错误分析

1、问题描述

启动tomcat部署项目时,报This is very likely to create a memory leak. Stack trace of thread错误。

29-May-2018 12:30:09.322 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file
29-May-2018 12:30:09.323 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
29-May-2018 12:30:09.427 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] 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.
29-May-2018 12:30:09.427 WARNING [localhost-startStop-1] 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.
29-May-2018 12:30:09.428 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [org.h2.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
29-May-2018 12:30:09.428 WARNING [localhost-startStop-1] 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:143)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:64)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 java.lang.Thread.run(Thread.java:745)

2、问题原因

tomcat启动奔溃,同时释放了jdbc连接。

3、解决方案

这种异常造成的原因千奇百怪,并没有统一的处理方案,以下是我遇到的不同情况采取的几种解决方案。

3.1、存在多个tomcat子线程

启动前tomcat意外退出,使用ps -ef | grep "tomcat名称"查看是不是有多个tomcat在启动,若有,Kill掉。

3.2、调整JVM参数

JAVA_OPTS=‘-server -Xms5120m -Xmx10240m -XX:PermSize=256m -XX:MaxNewSize=256m -XX:MaxPermSize=5120m ‘

3.3、去掉tomcat监听

tomcat 6.025以后引入了内存泄露侦测,对于垃圾回收不能处理的对像,它就会做日志。去掉监听的方法也很简单:

在tomcat的server.xml文件中,把

<!-- Prevent memory leaks due to use of particular java/javax APIs-->

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>这个监听给关了。

3.4、其他

如果以上方案无法解决问题,只能逐步排查,排查方案如下:
1.使用“之前部署正常的分支”(我们记为hoaven分支)部署项目;
2.若tomcat能正常启动,说明tomcat或服务器没有问题,检查自己的代码;
3.逐步检查自己的代码:从hoaven分支checkout一个分支(fixbug),然后将自己写的代码一点一点移至fixbug分支。
4.每移动一次代码,部署一次,若正常启动,继续移动代码;若报出以上错误,停止移动,检查本次移动的代码。

其实3.4方法很有效,特别是检查肉眼无法明了的莫名其妙的的bug。

记录下我某一次检查以上bug采用的3.4方案,得出的结果:

代码中,有一处注入报错很奇怪:

@Slf4j
@Component
public class RestAuthFilter extends FormAuthenticationFilter {

    @Resource
    MobileDeviceService mobileDeviceService;

    @Resource
    UserService userService;

    ...
}

@Slf4j
@Service
public class MobileDeviceServiceImpl implements MobileDeviceService {
    @Resource
    IHddBaseService hddBaseService;

    ...
}

MobileDeviceServiceUserService上的@Resource改为@Autowired部署则没有问题,思考一下:@Resource属于jdk的注解,@Autowired属于spring的注解,应该是注入RestAuthFilter时,在spring容器中没有找到MobileDeviceService和UserService的实例,@Resource会强制将MobileDeviceServiceUserService注入进来,而@Autowired采取的措施是不注入(或注入null)。这样一来,就会有新的问题,MobileDeviceServiceUserService实例为null,解决方案在后面的博客解决。

原文地址:https://www.cnblogs.com/jpfss/p/11828257.html

时间: 2024-11-08 22:46:23

This is very likely to create a memory leak. Stack trace of thread错误分析的相关文章

警告: The web application [ROOT] appears to have started a thread named [Thread-48] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:

1. 问题描述 tomcat跑web项目(其中依赖java项目) 出现大量上述警告 项目起不来 关键字 memory leak 内存泄漏 2. 解决方案 难道是程序写的有问题? 最终 将tomcat VM参数中 内存调大 解决了 -Xms512m -Xmx512m -Xmn300m -Xss2048k -XX:PermSize=512m -XX:MaxPermSize=512m 需要根据机器的配置做相应调整

tomcat 6.0.44 &ldquo;has failed to stop it. This is very likely to create a memory leak&rdquo; 问题调查

1. 问题起因 我们项目中缓存模块某个实现采用了ehcache(2.4.3),当项目部署到tomcat中后,对tomcat做停止服务操作,发现tomcat不能正常停止,报错 appears to have started a thread named [xxx] but has failed to stop it. This is very likely to create a memory leak.java进程不能正常结束,需要手动kill进程. 信息: Stopping service C

大神的---解决tomcat内存溢出问题----tomcat报错:This is very likely to create a memory leak问题解决

tomcat memory leak解决方案 这种问题在开发中经常会碰到的,看看前辈的总结经验 Tomcat内存溢出的原因  在生产环境中tomcat内存设置不好很容易出现内存溢出.造成内存溢出是不一样的,当然处理方式也不一样. 这里根据平时遇到的情况和相关资料进行一个总结.常见的一般会有下面三种情况:  1.OutOfMemoryError: Java heap space  2.OutOfMemoryError: PermGen space  3.OutOfMemoryError: unab

tomcat报错:This is very likely to create a memory leak问题解决

tomcat memory leak解决方案 这种问题在开发中经常会碰到的,看看前辈的总结经验 Tomcat内存溢出的原因  在生产环境中tomcat内存设置不好很容易出现内存溢出.造成内存溢出是不一样的,当然处理方式也不一样.  这里根据平时遇到的情况和相关资料进行一个总结.常见的一般会有下面三种情况:  1.OutOfMemoryError: Java heap space  2.OutOfMemoryError: PermGen space  3.OutOfMemoryError: una

tomcat关闭时Log4j2报错 Log4j Log4j2-TF-4-Scheduled-1 memory leak

出错信息: 23-Sep-2017 17:43:18.964 警告 [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [license] appears to have started a thread named [Log4j2-TF-4-Scheduled-1] but has failed to stop it. This is very li

Tomcat运行一段时间后,自动停止关闭,To prevent a memory leak,Druid 数据库连接自动关闭, the JDBC Driver has been forcibly unregistered.

1. Tomcat 错误日志 tail -100f tomcat9/logs/catalina.out 21-Sep-2017 23:05:39.301 INFO [Thread-5] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8809"]21-Sep-2017 23:05:39.352 INFO [Thread-5] org.apache.catalina.core.Stand

To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

1.错误描述 严重: The web application [/AMST] registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 八

解决:The web application [] registered the 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.

问题描述 在将Spring Boot程序打包生成的war包部署到Tomcat后,启动Tomcat时总是报错,但是直接在IDEA中启动Application或者用"java -jar"方式运行jar包时都能正常运行.报错信息如下: To prevent a memory leak, the JDBC Driver has been forcibly unregistered. (为了防止内存泄漏,已强制注销JDBC驱动程序.) 开发环境 Spring Boot + MySql + Spr

oracle 10gr2 ORA-27125: unable to create shared memory segment when run DBCA

I have installed 10gR2 on linux environment, When running DBCA it got filed with below error ORA-27125: unable to create shared memory segment SOLUTION: cd $ORACLE_HOME/bin   mv oracle oracle.bin     -- Paste it as one -   cat >oracle <<"EOF