次のエラーがログインしているベースの Web アプリケーション上stop
またはundeploy/redeploy
の:Spring framework 3.0.5
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>
Javadoc から:
**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();
上記のスニペットがクリーン シャットダウンを停止しているのだろうか? どんなポインタでも大歓迎です。