在stop
或undeploy/redeploy
基于Spring framework 3.0.5
Web 应用程序的以下错误已登录Tomcat7's catalina.out
:
SEVERE: The web application [/nomination##1.0-qa] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4f43af8f]) and a value of type [org.springframework.security.core.context.SecurityContextImpl] (value [org.springframework.security.core.context.SecurityContextImpl@ffffffff: Null authentication]) 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.
我最初考虑实施ServletContextListener
和close()
那里的上下文。但是,发现ContextLoaderListener
哪些工具ServletContextListener
是这样设置的web.xml
:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
来自 Javadocs:
**contextDestroyed**
public void contextDestroyed(ServletContextEvent event)
Close the root web application context.
Specified by:
contextDestroyed in interface ServletContextListener
所以,我的问题是为什么 ThreadLocal 没有被完全释放ContextLoaderListener.contextDestroyed()
?
我们遇到了PermGen
错误,在调查时发现了这一点。有几个地方有类似下面的代码:
ApplicationContext context = WebApplicationContextUtils
.getWebApplicationContext(se.getSession().getServletContext());
MyBeanClass x = context.getBean(
"myBean", MyBeanClass.class);
x.someMethod();
我想知道上面的代码片段是否正在停止干净关机?任何指针将不胜感激。