When tomcat is shut down you can see the following stacktrace:
INFO: Illegal access: this web application instance has been stopped already. Could not load [patterntesting.runtime.io.ExtendedFile]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [patterntesting.runtime.io.ExtendedFile]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1327)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1313)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1196)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
at patterntesting.runtime.monitor.AbstractMonitor.dumpMe(AbstractMonitor.java:160)
at patterntesting.runtime.monitor.AbstractMonitor.run(AbstractMonitor.java:92)
Can be reproduced with samples-jfs2010 and Tomcat 8. The complete stack trace is:
Last edit: Oliver Boehm 2017-07-15
It makes no sense to register the ClasspathMonitor (or any other Monitor class) as shutdown hook inside Tomcat (or other application server), because Tomcat itself stops the application at shutdown. So the ClasspathMonitor cannot be run from shutdown thread because application is already stopped).
For this reason the registration as shutdown hook is ignored now if the classloader of an application server is detected. If you want to dump the ClasspathMonitor before shutdown do it manually (via MBean / jconsole) or try to trigger it automatically via JMX before Tomcat is shut down.