I am building an application that relies heavily on XSL transformations. In order to avoid repetitive XSL loading/compiling and document fetching (within the XSL), I have created a class that encapsulates the Transformer object, creating it at instantiation and holding it until the application shuts down. Although the XSL itself is not particularly big, it fetches a large XML document (using document() function) which takes time. Therefore, caching is essential.

 

The application appears to work fine during testing and I haven’t yet seen any issues, however, when developing within Eclipse, code changes result in the Tomcat server republishing and reinitializing. After only two cycles of this, Tomcat exhibits errors. During each restart, the following SEVERE errors are found in the console:

 

SEVERE: The web application [/digitalguides] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@75bf2167]) and a value of type [net.sf.saxon.expr.sort.IntHashMap] (value [net.sf.saxon.expr.sort.IntHashMap@572a2d95]) 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.

Jan 31, 2012 5:31:01 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

SEVERE: The web application [/digitalguides] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1216bde8]) and a value of type [net.sf.saxon.expr.sort.IntHashMap] (value [net.sf.saxon.expr.sort.IntHashMap@130dd39f]) 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.

Jan 31, 2012 5:31:02 PM org.apache.catalina.core.ApplicationContext log

 

Then, on the 3rd re-init, Tomcat appears to have a serious problem with the following message:

 

INFO: Initializing Spring root WebApplicationContext

Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]"

 

When I click the “Server Restart” button, it logs the following errors before finally restarting.

 

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_stop]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/digitalguides]] in state [STARTING_PREP]

       at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)

       at java.util.concurrent.FutureTask.get(FutureTask.java:111)

       at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1156)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

       at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1540)

       at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1530)

       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

       at java.util.concurrent.FutureTask.run(FutureTask.java:166)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

       at java.lang.Thread.run(Thread.java:722)

Caused by: org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_stop]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/digitalguides]] in state [STARTING_PREP]

       at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:408)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:219)

       ... 7 more

 

Jan 31, 2012 5:41:48 PM org.apache.catalina.core.ContainerBase stopInternal

SEVERE: A child container failed during stop

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina].StandardHost[localhost]]

       at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)

       at java.util.concurrent.FutureTask.get(FutureTask.java:111)

       at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1156)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

       at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:502)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

       at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:748)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

       at org.apache.catalina.startup.Catalina.stop(Catalina.java:691)

       at org.apache.catalina.startup.Catalina.start(Catalina.java:653)

       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

       at java.lang.reflect.Method.invoke(Method.java:601)

       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)

       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)

Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina].StandardHost[localhost]]

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)

       at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1540)

       at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1530)

       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

       at java.util.concurrent.FutureTask.run(FutureTask.java:166)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

       at java.lang.Thread.run(Thread.java:722)

Caused by: org.apache.catalina.LifecycleException: A child container failed during stop

       at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1163)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

       ... 7 more

 

Jan 31, 2012 5:41:48 PM org.apache.catalina.startup.Catalina stop

SEVERE: Catalina.stop

org.apache.catalina.LifecycleException: Failed to stop component [StandardServer[8005]]

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)

       at org.apache.catalina.startup.Catalina.stop(Catalina.java:691)

       at org.apache.catalina.startup.Catalina.start(Catalina.java:653)

       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

       at java.lang.reflect.Method.invoke(Method.java:601)

       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)

       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)

Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardService[Catalina]]

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)

       at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:748)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

       ... 8 more

Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina]]

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)

       at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:502)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

       ... 10 more

Caused by: org.apache.catalina.LifecycleException: A child container failed during stop

       at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1163)

       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

       ... 12 more

 

Does anyone have any ideas what may be causing this to happen? I would really love to clear this up but I’ve hit a wall.

 

Thanks!

Gerry