Any idea how to prevent the following logged ERROR on shutdown of Tomcat (i.e. what cleanup do I need to do on my shutdown of my application that uses Websockets):
[2018-11-15 18:33:20,353] [localhost-startStop-2] ERROR (org.apache.catalina.loader.WebappClassLoaderBase) The web application [myapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@bb5f817]) and a value of type [org.glassfish.grizzly.ThreadCache.ObjectCache] (value [org.glassfish.grizzly.ThreadCache$ObjectCache@3d25e85f]) 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.
I'm going to have to assume that you're doing that weird thing where a webapp uses Glassfish resources even though the webapp server itself is Tomcat.
It sounds like you are spawning threads in your webapp. The J2EE standard expressly forbids that in any code that's being executed in response to a servlet request - and that includes servlet code itself. Servlets run under threads that are pulled from a pool, used just long enough to service the request, then returned to the pool. If you spawn a subthread of that thread, you end up polluting the thread pool, which can randomly crash Tomcat.
In the event that you spawn a thread(s) in ServletContextListener - which, unlike servlets, is allowed to spawn child threads, you are obligated to terminate those threads in a corresponding shutdown ServletContextListener method. Failing to do so will annoy Tomcat and delay its termination, since a JVM cannot exit to the OS until all of its threads have terminated.
An IDE is no substitute for an Intelligent Developer.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database