设为首页 收藏本站
查看: 663|回复: 0

[经验分享] tomcat的一个常见错误

[复制链接]

尚未签到

发表于 2018-11-29 10:45:42 | 显示全部楼层 |阅读模式
  现象:
  上次同事在热部署应用到liferay服务器上时,遇到了以下错误:


  • Sep 21, 2012 3:19:06 AM org.apache.catalina.startup.HostConfig deployDirectory

  • INFO: Deploying web application directory /home/portal/liferay-container-1.0.0-SNAPSHOT/standalone/liferay-portal/community-edition-liferay-portal-tomcat-6.1.0/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/paas_integration_portlet

  • Sep 21, 2012 3:19:06 AM org.apache.catalina.core.StandardContext startInternal

  • SEVERE: Error listenerStart

  • Sep 21, 2012 3:19:06 AM org.apache.catalina.core.StandardContext startInternal

  • SEVERE: Context [/paas_integration_portlet] startup failed due to previous errors

  • Sep 21, 2012 3:19:06 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

  • SEVERE: The web application [/paas_integration_portlet] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@3e043340]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

  • Sep 21, 2012 3:19:06 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

  • SEVERE: The web application [/paas_integration_portlet] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5c0ce8f]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

  • Sep 21, 2012 3:19:06 AM org.apache.coyote.AbstractProtocol start

  • INFO: Starting ProtocolHandler ["http-bio-8080"]

  • Sep 21, 2012 3:19:06 AM org.apache.coyote.AbstractProtocol start

  • INFO: Starting ProtocolHandler ["ajp-bio-8009"]

  • Sep 21, 2012 3:19:06 AM org.apache.catalina.startup.Catalina start

  • INFO: Server startup in 37724 ms

  基于我的以前经验,这是"类加载器泄露“的问题,具体细节参见我的以下邮件回复:
Reason:




This is very common in Tomcat .







We all know (1) ThreadLocal is used for holding variables per thread.



                         (2) Tomcat supports multi-threads.
                        (3) The default GC mechanism for tomcat is “object reference”











So  the process is ,when we redeploy a portlet ,then the WebClassloader  will load all the necessary classes and jars which required by this  portlet ,and the threadlocal is used for identifying the thread . But  when we destroy the portlet(redeploy or remove) ,though the portlet is  removed ,but the threadlocal  value didn’t remove ,(which means the  object reference number still >0) ,so the classes loaded by  WebappClassLoader can’t not be gc , that’s a very famous topic   “Classloader leak”







My highlighted part is my understanding to this problem and it can explains what Judith has highlighted .














Solution:







“Classloader  leak” issue happened since the first version of tomcat ,and it always a  challenging work , as I know ,since tomcat 7 (because our Liferay 6.1  based on tomcat 7) has added some detection mechanism to detect the  classloader leak issue ,that’s why it report “SEVERE”   ,if you familiar  with tomcat 5 or 6 ,it just shutdown without any useful information.







Up  to now just as I know ,we have no solution about it ,maybe we need to  new version of tomcat to fix it .  If often meet with it ,I suggest we  re-start the liferay.














Referenced Articles:







http://wiki.apache.org/tomcat/MemoryLeakProtection#customThreadLocal



https://issues.apache.org/bugzilla/show_bug.cgi?id=49159
http://www.javacodegeeks.com/2012/05/threading-stories-threadlocal-in-web.html










Charles





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-641085-1-1.html 上篇帖子: 【tomcat】tomcat部署项目实验 下篇帖子: Tomcat性能优化及JVM内存工作原理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表