After a bit of debugging, I found the issue. The stack traces below are on 8.0.12-src.
The bug occurs at this stack: > StandardContext.reload() line: 3779 > HostConfig.reload(HostConfig$DeployedApplication) line: 1306 > HostConfig.checkResources(HostConfig$DeployedApplication) line: 1238 > HostConfig.check(String) line: 1493 HostConfig.checkResources(DeployedApplication) runs through the branch: > if (app.hasDescriptor && resource.getName().toLowerCase( > Locale.ENGLISH).endsWith(".war")) { ... } It calls ExpandWar.delete( docBaseFile ), which is the unpacked webapp directory. Then, checkResources calls reload(app) - which invokes the context listener. The ClassLoader eventually gets down to this stack: > DirResourceSet.getResource(String) line: 100 StandardRoot.getResourceInternal(String, boolean) line: 280 > Cache.getResource(String, boolean) line: 65 > StandardRoot.getResource(String, boolean, boolean) line: 216 > StandardRoot.getClassLoaderResource(String) line: 225 > WebappClassLoader.findResourceInternal(String, String) line: 2556 > WebappClassLoader.findClassInternal(String) line: 2410 > WebappClassLoader.findClass(String) line: 880 > WebappClassLoader.loadClass(String, boolean) line: 1290 > WebappClassLoader.loadClass(String) line: 1173 > TestcaseContextListener.contextDestroyed(ServletContextEvent) line: 23 > StandardContext.listenerStop() line: 4792 > StandardContext.stopInternal() line: 5392 > StandardContext(LifecycleBase).stop() line: 232 > StandardContext.reload() line: 3768 > HostConfig.reload(HostConfig$DeployedApplication) line: 1306 > HostConfig.checkResources(HostConfig$DeployedApplication) line: 1238 > HostConfig.check(String) line: 1493 Unfortunately, checkResources just deleted the base directory. The ClassLoader is looking for /WEB-INF/classes/com/avadyne/ThisClassNotFound.class, but that path no longer exists. Most of the functions in the stack return null, and findClassInternal(String) throws the ClassNotFoundError at line 906. OK, how should this be fixed? Should the ClassLoader fall back to the compressed WAR? Should the DocBase be deleted after the context is stopped? On Sun, Mar 22, 2015 at 2:26 PM, Austin Jones <a...@avadynehealth.com> wrote: > I was able to reproduce the issue in a simple testcase application: > https://github.com/austinjones/ClassNotFoundGenerator/ > > On Sun, Mar 22, 2015 at 1:45 PM, Austin Jones <a...@avadynehealth.com> > wrote: > >> I put 8.0.20 on a testing machine, and saw the same issue. >> >> On Sun, Mar 22, 2015 at 12:15 PM, Christopher Schultz < >> ch...@christopherschultz.net> wrote: >> >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA256 >>> >>> Austin, >>> >>> On 3/21/15 6:19 PM, Austin Jones wrote: >>> > I'm having an issue with Tomcat 8.0.12 when undeploying contexts. >>> > I have autoDeploy turned off, and am pushing WARs+context.xmls >>> > through the Tomcat manager's deploy command. >>> > >>> > I have several ServletContextListeners that handle proper context >>> > shutdown. The ones that cause the issue look like this: >>> > >>> > @Override public synchronized void contextInitialized( >>> > ServletContextEvent event ) { if( enabled ) { >>> > MyClass.initialize(); } } >>> > >>> > @Override public synchronized void contextDestroyed( >>> > ServletContextEvent event ) { MyClass.release(); } >>> > >>> > If the 'enabled' flag is not set, and MyClass was not loaded >>> > anywhere else in the app, the webapp ClassLoader tries to load the >>> > class while the context is shutting down. It throws this >>> > exception: java.lang.NoClassDefFoundError: some/package/MyClass at >>> > some.package.MyListener.contextDestroyed(SingletonCleaner.java:na) >>> > at >>> > >>> org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4792) >>> > >>> > >>> at >>> > >>> org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5392) >>> > >>> > >>> at >>> > org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) >>> > >>> > >>> at >>> > >>> org.apache.catalina.core.StandardContext.reload(StandardContext.java:3768) >>> > >>> > >>> at >>> > org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1306) >>> > >>> > >>> at >>> > >>> org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1238) >>> > >>> > >>> at >>> > org.apache.catalina.startup.HostConfig.check(HostConfig.java:1493) >>> > at sun.reflect.GeneratedMethodAccessor574.invoke(Unknown Source) >>> > at >>> > >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>> > >>> > >>> at java.lang.reflect.Method.invoke(Method.java:483) >>> > at >>> > >>> org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) >>> > >>> > >>> at >>> > >>> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) >>> > >>> > >>> - -- >>> > Caused by: java.lang.ClassNotFoundException: some.package.MyClass >>> > at >>> > >>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1320) >>> > >>> > >>> at >>> > >>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1173) >>> > >>> > >>> ... 45 more >>> > >>> > I set WebappClassLoader logging levels to FINE, and got this >>> > output: 21-Mar-2015 14:59:46.493 FINE [localhost-startStop-1] >>> > org.apache.catalina.loader.WebappClassLoader.loadClass >>> > loadClass(some.package.MyClass, false) 21-Mar-2015 14:59:46.493 >>> > FINE [localhost-startStop-1] >>> > org.apache.catalina.loader.WebappClassLoader.findClass >>> > findClass(some.package.MyClass) >>> > >>> > Any ideas why the class loader is throwing the errors? >>> >>> Could you try again with the latest 8.0.20? There was a change in >>> 8.0.18 that /might/ impact your situation: >>> https://bz.apache.org/bugzilla/show_bug.cgi?id=57446 >>> >>> - -chris >>> -----BEGIN PGP SIGNATURE----- >>> Version: GnuPG v1 >>> Comment: GPGTools - http://gpgtools.org >>> >>> iQIcBAEBCAAGBQJVDxTQAAoJEBzwKT+lPKRYG3UP/1WvGcySKDtqMZMoTVH5H3mW >>> EHZiaZubtiaReAxw6z11yLijMU2TI8a7mwYz5fi34M7AQ7nke3R9Mm3p3oojfJY6 >>> jLVSTfe2fKYAK5rAdCNnuY2K/VVtpGR+q/KYLbsPkuIQYclamHtGbFuFxmUMm73O >>> NQ0QdXreyPQrdeoY8sNz01Dx8nAgI+3YNAbv1TKSbXbh4qfLnoLNePBoqfu0azqC >>> B0/rNw6ovzYcPo9BYplwK23BjxDa+P9F7wOxxSk8nf3tEpksnRC2EsUNL9kbGtDx >>> TV/7xl8Ln3DpONzETGCLbrf5W6Cj1MkAiSBk5iOmbTQdCvetpQNB5D57ZLBiFMy7 >>> CEQrpWK9rQhmklmElxsmO0UvU/BLPoUtbv5BbJNnm3cYVgChgRrSpVVDtv8l33iF >>> dAQCTXqtyHl46tR7lbkoeNO9/YHtJJQ93Rmw3wF+UlloXi7pRjJE1NHEbbzllUIj >>> ddE8eqjP20ZkOrNa0I6vuk8Z6Tkf4aqIkvjMtnfyMb+9lImF33Y4PWsLRO8rvUmS >>> CgNWebKGfNVoHrMJpSh/BOf1mkKkTE38hBUyRSZ66VMbTS0mAMr5nqnNfrKTm5b/ >>> nr9K0rcvusvs9sQyjBNEMg761ZGWcPGYWtQZNnyMHL5KmI4NF8OeSSlUO8V1Yvv7 >>> At0sF5VE58lDPP/VTDts >>> =GVSN >>> -----END PGP SIGNATURE----- >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >>> For additional commands, e-mail: users-h...@tomcat.apache.org >>> >>