当我从 Tomcat 取消部署我的应用程序时,我在 Tomcat 日志中看到以下错误。可能是什么问题?我该如何解决这个问题。
---------------------------- Tomcat日志----------------- ----------
SEVERE: The web application [/dfsmonitor] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@6ca32e]) and a value of type [com.sun.xml.stream.XMLReaderImpl] (value [com.sun.xml.stream.XMLReaderImpl@e01430]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Jul 1, 2012 10:18:20 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: Unable to determine string representation of value of type [com.sun.xml.stream.writers.XMLStreamWriterImpl]
java.lang.UnsupportedOperationException
at com.sun.xml.stream.writers.XMLStreamWriterImpl.entrySet(XMLStreamWriterImpl.java:2134)
at java.util.AbstractMap.toString(AbstractMap.java:478)
at org.apache.catalina.loader.WebappClassLoader.clearThreadLocalMap(WebappClassLoader.java:2433)
at org.apache.catalina.loader.WebappClassLoader.clearReferencesThreadLocals(WebappClassLoader.java:2349)
at org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1921)
at org.apache.catalina.loader.WebappClassLoader.stop(WebappClassLoader.java:1833)
at org.apache.catalina.loader.WebappLoader.stop(WebappLoader.java:740)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4913)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:932)
at org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1357)
at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1328)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:326)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1094)
at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1106)
at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:468)
at org.apache.catalina.core.StandardService.stop(StandardService.java:604)
at org.apache.catalina.core.StandardServer.stop(StandardServer.java:788)
at org.apache.catalina.startup.Catalina.stop(Catalina.java:662)
at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Jul 1, 2012 10:18:20 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/dfsmonitor] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1bf8785]) and a value of type [com.sun.xml.stream.writers.XMLStreamWriterImpl] (value [Unknown]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Jul 1, 2012 10:18:20 PM org.apache.coyote.http11.Http11AprProtocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
请让我知道可能是什么问题。
答案 0 :(得分:0)
您可以避免将XMLStreamWriterImpl实例放入线程本地,这样一旦关闭,Tomcat就不会在删除它们时遇到任何问题。
但是除了在Servlet上实际实现destroy方法,或者在Spring等环境中注册关闭钩子并跟踪你曾经设置成threadlocals的所有值,以便你可以在关机时删除它们,我不会认为你真的需要担心这个问题。虽然您或您正在使用的代码很奇怪,但是将这个值存储到线程本地 - 通常流编写器很快就被创建和销毁,并且不会持续很长时间。