Using Tomcat manager in tomcat 7.0 + sping MVC, Webapp reload gives apachelifecycle exception. It all starts up fine and works fine when started normally. After the startup for reloading the webapp, we use the tomcat manager. In tomcat manager, upon clicking the reload button it says reload successful ( this enables the start button). Upon clicking the start button in the tomcat it throws a apachelifecyle exception. The issue is in the WebappClassLoader.java (Line: 2598) I have added a null check and every thing is working fine. Changed code snippet ( From Line number 2596, changed line 2598): if (o instanceof Collection<?>) { Iterator<?> iter = ((Collection<?>) o).iterator(); while (iter != null && iter.hasNext()) { // Added iter !=null Object entry = iter.next(); if (loadedByThisOrChild(entry)) { return true; } } }
Stack Trace: 2013-03-27 01:13:39,153 [http-bio-443-exec-24] ERROR StandardContext - Exception stopping Context with name [/webtest] org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webtest]] at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3913) at org.apache.catalina.manager.ManagerServlet.reload(ManagerServlet.java:953) at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:364) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.apache.catalina.LifecycleException: Failed to stop component [WebappLoader[/webtest]] at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5521) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) ... 24 more Caused by: java.lang.NullPointerException at org.apache.catalina.loader.WebappClassLoader.loadedByThisOrChild(WebappClassLoader.java:2598) at org.apache.catalina.loader.WebappClassLoader.checkThreadLocalMapForLeaks(WebappClassLoader.java:2515) at org.apache.catalina.loader.WebappClassLoader.checkThreadLocalsForLeaks(WebappClassLoader.java:2455) at org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1996) at org.apache.catalina.loader.WebappClassLoader.stop(WebappClassLoader.java:1902) at org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:661) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) ... 26 more 2013-03-27 01:13:39,155 [http-bio-443-exec-24] INFO LifecycleBase - The stop() method was called on component [org.apache.catalina.deploy.NamingResources@2d204c14] after stop() had already been called. The second call will be ignored.
Hi, A null check is not performed because the standard Oracle JDK j.u.Collection implementations return a non null iterator even when the Collection is empty. Can you please give an information for the j.u.Collection implementation that you use? Also in Tomcat version 7.0.36 there is an additional check so that a failure in the memory leak detection code does not prevent the Context from stopping. Please use the latest Tomcat version (currently 7.0.39). Regards Violeta
We are using the standard j.u.Collection. I have already tested the 7.0.39 and the issue is not seen. But we need the issue to be fixed for the 7.0.30.
(In reply to comment #3) > But we need the issue to be fixed for the 7.0.30. The only way a bug in a prior version can be fixed is by installing a later version, or by ferreting out the changes in the relevant SVN revision (or revisions), back-porting them to your Tomcat version, and building from source. No one is going to do that for you, since 7.0.39 already appears to fix the problem; your easiest way forward is just to install it.
Done! Will go with the custom code till we migrate to 7.0.39. Thanks for the updates...
The bug persists in the 7.0.30 and has been addressed in the latest code and hence cannot be marked as invalid. Should be marked as a wont fix for the 7.0.30 or a resolved for the 7.0.39. Cant be invalid in any case! Can reproduce this issue at will in 7.0.30
*** This bug has been marked as a duplicate of bug 54497 ***