Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-502

Usage of XmlBeans triggers "clearThreadLocalMap" warnings in Tomcat with XSSF

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Version 2.3
    • Version 3.1.0
    • None
    • None
    • Apache Tomcat 6.0.35, Apache POI 3.9-20121203, Java SE 6/7, any operating system

    Description

      Hello,

      After creating this issue https://issues.apache.org/bugzilla/show_bug.cgi?id=55149 I was advised to create the issue here. This appears to be similar to https://issues.apache.org/jira/browse/XMLBEANS-103 but as it's marked as FIXED and as I'm using a more recent version (and as it's not completely identical), I'm creating a new issue.

      It would appear that XMLBeans is creating (and not clearing) ThreadLocal variables. This causes Tomcat to complain about classloader leaks (see messages below). Based on information in XMLBEANS-103, I have tried to coax the JVM to clear the ThreadLocal (by performing garbage collection on the JVM), but that doesn't clear the ThreadLocals, even if allowing time to elapse AFTER using POI to process an XSSF document and BEFORE stopping Tomcat.

      To workaround this, we're having to impose long downtime when a restart is required. Perhaps a utility class within XMLBeans could be made available with the POI distribution such as:

      XMLBeansCache.clearThreadLocals()

      ...that I could call from a "finally" block after processing the XSSF document?

      Here's the information from Tomcat's logs:
      SEVERE: The web application [/foobar] created a ThreadLocal with key of type [org.apache.xmlbeans.XmlBeans$1] (value [org.apache.xmlbeans.XmlBeans$1@7d3aace]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference@5972be65]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
      Jun 26, 2013 7:01:56 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
      SEVERE: The web application [/foobar] created a ThreadLocal with key of type [org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$1] (value [org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$1@7c3206c3]) and a value of type [java.util.ArrayList] (value [[java.lang.ref.SoftReference@385a2be8]]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
      Jun 26, 2013 7:01:56 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
      SEVERE: The web application [/foobar] created a ThreadLocal with key of type [org.apache.xmlbeans.impl.store.Locale$1] (value [org.apache.xmlbeans.impl.store.Locale$1@27f8a93f]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference@362f7b99]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
      Jun 26, 2013 7:01:56 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
      SEVERE: The web application [/foobar] created a ThreadLocal with key of type [org.apache.xmlbeans.impl.store.CharUtil$1] (value [org.apache.xmlbeans.impl.store.CharUtil$1@675b9599]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference@2dbaa4d2]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.

      Attachments

        1. leak1.png
          366 kB
          Valentin Popov
        2. leak2.png
          333 kB
          Valentin Popov

        Activity

          People

            dominik.stadler@gmx.at Dominik Stadler
            cbr.reflexe Christopher Brown
            Votes:
            14 Vote for this issue
            Watchers:
            16 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m