Search code examples
javaweb-servicestomcatsoapjax-ws

Tomcat throws SEVERE warning when undeployed


Tomcat version: 7.0.41 (also tried 8.0.32)
JRE: 6u42
Wrote a very simple JAX-WS application (as a test). The application at the moment simply displays wsdl file when "?wsdl" is used and when a SOAP request is given, am just returning a string.

@WebService
public class SOAPWithWS
{
    @WebMethod
    public String HelloTest(String sMessage)
    {
        return "Received : " + sMessage;
    }
}

When I try to undeploy the context, it gives me a warning as below:

Mar 09, 2016 1:54:24 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WS] created a ThreadLocal with key of type [com.sun.xml.bind.v2.runtime.Coordinator$1] (value [com.sun.xml.bind.v2.runtime.Coordinator$1@3e26faf2]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@712545be]) 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.
Mar 09, 2016 1:54:24 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WS] created a ThreadLocal with key of type [com.sun.xml.bind.v2.ClassFactory$1] (value [com.sun.xml.bind.v2.ClassFactory$1@4605f6fa]) and a value of type [java.util.WeakHashMap] (value [{class com.sun.xml.ws.runtime.config.TubelineDefinition=java.lang.ref.WeakReference@3199bb00, class com.sun.xml.ws.runtime.config.TubeFactoryConfig=java.lang.ref.WeakReference@63c41670, class javax.xml.bind.annotation.adapters.CollapsedStringAdapter=java.lang.ref.WeakReference@5e9d463b, class com.sun.xml.ws.runtime.config.Tubelines=java.lang.ref.WeakReference@276dfc04, class javax.xml.bind.annotation.W3CDomHandler=java.lang.ref.WeakReference@25bc7ed5, class java.util.ArrayList=java.lang.ref.WeakReference@7a2ae54d, class com.sun.xml.ws.runtime.config.MetroConfig=java.lang.ref.WeakReference@163460e4, class com.sun.xml.ws.runtime.config.TubeFactoryList=java.lang.ref.WeakReference@48c5241f}]) 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.
Mar 09, 2016 1:54:24 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WS] created a ThreadLocal with key of type [org.glassfish.gmbal.generic.OperationTracer$1] (value [org.glassfish.gmbal.generic.OperationTracer$1@6c6948c]) and a value of type [java.util.ArrayList] (value [[]]) 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.

This happens everytime I tested. The same doesn't happen on GlassFish server (just tried to test this scenario). Any idea what is happening and how to eliminate this problem?


Solution

  • This warning is shown when the JAX-WS implementation is added as a library for the corresponding project.

    Rather than adding the JAX-WS implementation to the project, add it to the list of libraries on Tomcat itself. Eg: On Linux, if Tomcat is installed within /usr/java/Tomcat-7, then the JAX-WS library must be included within /usr/java/Tomcat-7/lib/.

    If you do not want to add the libraries straight into Tomcat, then make sure to restart Tomcat completely whenever the context is undeployed. If you restart Tomcat everytime when the context is undeployed, you could safely ignore the warning.