users@jersey.java.net

[Jersey] Jersey, JAXBContextResolver, and Tomcat memory leak detection

From: Mark Petrovic <mspetrovic_at_gmail.com>
Date: Tue, 15 Mar 2011 15:06:25 -0700

Hi. Tomcat 7 has memory leak detection, and I'm seeing these sorts of
messages when I redeploy an app that uses a JAXBContext instance as a
@Provider:

@Provider
public class JAXBContextResolver implements ContextResolver<JAXBContext> {
...
}


Mar 15, 2011 10:23:36 AM org.apache.catalina.loader.WebappClassLoader
checkThreadLocalMapForLeaks
SEVERE: The web application [/fooapp] created a ThreadLocal with key
of type [com.sun.xml.bind.v2.runtime.Coordinator$1] (value
[com.sun.xml.bind.v2.runtime.Coordinator$1_at_77198eb6]) and a value of
type [java.lang.Object[]] (value [[Ljava.lang.Object;@2ee88bd0]) 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.

Is Jersey placing things in a persistent ThreadLocal that perhaps are
not being removed when a webapp is redeployed? If yes, how can I
manually remove these instances?


-- 
Mark