Stop applying the Times in TOMCAT7 error: created a ThreadLocal with key of type

Source: Internet
Author: User

stop applying the Times error under TOMCAT7: Created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.containerimpl$10]

Info:a valid Shutdown command was received via the shutdown port. Stopping the Server instance. APR 10:36:52 AM org.apache.coyote.AbstractProtocol pauseinfo:pausing protocolhandler ["http-bio-8080"]apr 02, 2 015 10:36:52 AM org.apache.coyote.AbstractProtocol pauseinfo:pausing protocolhandler ["ajp-bio-8009"]apr 02, 2015 10:36 : Org.apache.catalina.core.StandardService stopinternalinfo:stopping Service CATALINAAPR, 10:36:52 am ORG.A Pache.catalina.core.ApplicationContext loginfo:closing Spring Root webapplicationcontextapr, 10:36:52 AM Org.apache.catalina.loader.WebappClassLoader checkthreadlocalmapforleaks<span style= "color: #ff0000;" >severe:the Web application [/TECHREVMANAGER5] created a ThreadLocal with key of type [Com.opensymphony.xwork2.inject. CONTAINERIMPL$3] (value [[email protected]]) and a value of type [java.lang.object[]] (value [[ljava.lang.object;@ 7F5846D0] Failed to remove it when the Web application is stopped. Threads is Going to is renewed over time to try and avoid a probable memory leak.</span>apr, 10:36:52 AM org.apache.co Yote. Abstractprotocol stopinfo:stopping Protocolhandler ["http-bio-8080"]APR, 10:36:52 AM Org.apache.coyote.AbstractProtocol stopinfo:stopping Protocolhandler ["ajp-bio-8009"]APR, 10:36:52 AM Org.apache.coyote.AbstractProtocol destroyinfo:destroying Protocolhandler ["http-bio-8080"]APR, 10:36:52 AM Org.apache.coyote.AbstractProtocol destroyinfo:destroying Protocolhandler ["ajp-bio-8009"]


let's start with the development environment checklist.
Tomcat-7.0.59
xwork-core-2.2.1
struts2-core-2.2.1


Analysis Process
From the error situation, there is a problem with the class Com.opensymphony.xwork2.inject.ContainerImpl in Xwork.
Download xwork-core-2.2.1 source, open the Containerimpl file, see the code in line 557-583, there is a problem with memory not released:
Here, a one-dimensional array is initialized in the thread variable threadlocal<object[]> localcontext =  new threadlocal<object[]> () {@ overrideprotected object[] InitialValue () {  return new object[1];}  };/ Looks up thread local context. Creates (and removes) a new context if* necessary.*/<t> T Callincontext (contextualcallable<t> callable) {Obje ct[] Reference = Localcontext.get (), if (reference[0] = = null) {  reference[0] = new Internalcontext (this);  try {return Callable.call ((Internalcontext) reference[0]);  } finally {//only remove the context if this call created I T.reference[0] = null;//Only the elements in the array are freed, and the array object of the thread variable is not freed  }} else {  //Someone else will clean up the this context.  Return Callable.call ((Internalcontext) reference[0]);}}

Workaround
Problems and causes are found, then the solution is simple, there are two options to choose:
    1. Upgrade the version of the jar file for xwork, according to my check, this problem does not exist from the xwork-core-2.3.3 and later versions. Accordingly, you may need to upgrade your struts2-core-2.3.3 above.
    2. Modify the Com.opensymphony.xwork2.inject.ContainerImpl file in the xwork-core-2.2.1, and then put it in the Classpath path (to replace the class in the Jar file)
<T> T Callincontext (contextualcallable<t> callable) {object[] reference = Localcontext.get (); if (reference [0] = = null) {  reference[0] = new Internalcontext (this);  try {return Callable.call ((Internalcontext) reference[0]);  } finally {//only remove the context if this call created I T.reference[0] = null;//to release the array object of the thread variable This.localContext.remove ();}  } else {  //Someone else would clean up this context.  Return Callable.call ((Internalcontext) reference[0]);}}


Stop applying the Times in TOMCAT7 error: created a ThreadLocal with key of type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.