The web application [] appears to have started ...
2016-06-20 15:48
417 查看
The web application [] appears to have started ...
ilxlf
发布时间: 2012/07/25 11:51
阅读: 468
收藏: 0
点赞: 0
评论: 0
有看到过这个标题的人吗?我的Tomcat出什么问题了?
有一个servlet,它在init方法里面实例化了一个线程类。这个类里面启动了若干个daemon线程。
有一个listener,它在contextDestroyed方法里面关闭这个线程类。
在catalina.out里面出现了这样的日志。
在下面的这个link里面,apache官方给了一些说明:
http://wiki.apache.org/tomcat/MemoryLeakProtection
其中就包含了这种问题。具体的原因说的很清楚:
Here, when the app is stopped, the webapp classloader is still referenced by the spawned thread both through its context classloader and its current call stack (the anonymous Thread subclass is loaded by the webapp classloader).
When stopping an application, tomcat checks the context classloader of every Thread, and if it is the same as the app being stopped, it logs the following message :
当前app的classloader的引用指向到里我的线程类。
修改方法参照官方说明。
还有另外一种修改方法。
在我们的线程类里面加入stop方法:
然后在contextDestroyed方法里面调用stopRun方法。
The web application [] appears to have started ...
ilxlf
发布时间: 2012/07/25 11:51
阅读: 468
收藏: 0
点赞: 0
评论: 0
有看到过这个标题的人吗?我的Tomcat出什么问题了?
有一个servlet,它在init方法里面实例化了一个线程类。这个类里面启动了若干个daemon线程。
有一个listener,它在contextDestroyed方法里面关闭这个线程类。
在catalina.out里面出现了这样的日志。
在下面的这个link里面,apache官方给了一些说明:
http://wiki.apache.org/tomcat/MemoryLeakProtection
其中就包含了这种问题。具体的原因说的很清楚:
Here, when the app is stopped, the webapp classloader is still referenced by the spawned thread both through its context classloader and its current call stack (the anonymous Thread subclass is loaded by the webapp classloader).
When stopping an application, tomcat checks the context classloader of every Thread, and if it is the same as the app being stopped, it logs the following message :
当前app的classloader的引用指向到里我的线程类。
修改方法参照官方说明。
leakingThread.setContextClassLoader(null)
还有另外一种修改方法。
在我们的线程类里面加入stop方法:
class Example implements Runnable { private volatile boolean isStop; private Thread runThread; @Override public void run() { runThread = Thread.currentThread(); isStop = false; while(!isStop){ try { process(); } catch (XMPPException e) { log.error("Example logic exception.", e); } } } public void stopRun() { isStop = true; if(runThread != null) { runThread.interrupt(); } }
然后在contextDestroyed方法里面调用stopRun方法。
相关文章推荐
- iOS url的正则表达式
- 看懂Android学习最佳路线
- android权限相关的知识
- 【Android】在任何View上添加红点★★★★★★★
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- iOS Appstore打出的包为啥偏大?怎么样减小iOS包的大小?
- Android Studio 连接提交Git
- 1.2、Android Studio为新设备创建一个模块
- 1.2、Android Studio为新设备创建一个模块
- Android:layout_weight详解
- IOS中实现图片点击全屏预览
- android studio匪夷所思的问题
- 在Android M及更高版本中使用 Settings.System 抛出异常"You cannot keep your settings in the secure settings. "
- Android-启动模式task-lunchmodle-intent flag 总结
- Android 设计模式—单例模式
- Swift: 你好, UIKit!
- 为您揭开runtime的神秘面纱 <一>
- 安卓集成SharedSDK第三方平台分享
- The web application [/jenkins] appears to have started a thread named [Executor [问题点数:20分]
- Android中常见的正则表达式工具类