5

当我从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

请让我知道可能是什么问题。

4

1 回答 1

1

您可以避免将 XMLStreamWriterImpl 实例放入线程本地,这样在关闭 Tomcat 时删除它们不会有任何问题。

但是除了在 Servlet 上实际实现 destroy 方法,或者在 Spring 等环境中注册关闭钩子并跟踪您曾经设置到 threadlocals 中的所有值,以便您可以在关闭时删除它们,我不认为你真的需要担心这个。尽管您或您正在使用的代码将此值存储到线程本地很奇怪 - 通常流编写器会快速创建和销毁并且不会持续很长时间。

于 2012-09-01T00:11:46.650 回答