tomcat的一个常见错误
现象:上次同事在热部署应用到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 startup failed due to previous errors
[*]
[*]Sep 21, 2012 3:19:06 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
[*]
[*]SEVERE: The web application created a ThreadLocal with key of type (value ) and a value of type (value ) 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 created a ThreadLocal with key of type (value ) and a value of type (value ) 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”
Sothe process is ,when we redeploy a portlet ,then the WebClassloaderwill load all the necessary classes and jars which required by thisportlet ,and the threadlocal is used for identifying the thread . Butwhen we destroy the portlet(redeploy or remove) ,though the portlet isremoved ,but the threadlocalvalue didn’t remove ,(which means theobject reference number still >0) ,so the classes loaded byWebappClassLoader 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:
“Classloaderleak” issue happened since the first version of tomcat ,and it always achallenging work , as I know ,since tomcat 7 (because our Liferay 6.1based on tomcat 7) has added some detection mechanism to detect theclassloader leak issue ,that’s why it report “SEVERE” ,if you familiarwith tomcat 5 or 6 ,it just shutdown without any useful information.
Upto now just as I know ,we have no solution about it ,maybe we need tonew version of tomcat to fix it .If often meet with it ,I suggest were-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]