Hash: SHA256


On 2/2/18 8:24 AM, Luib-Finetti, Carlo wrote:
> Under Windows 10, my local development Tomcat Version 8.5.11
> reports a lot of warnings about not stopped threads. For example: "
> The web application [webdms-jadice] appears to have started a
> thread named [pool-1-thread-1-Logging Task Scheduler] but has
> failed to stop it." Our application support team reports the same
> issues running Tomcat within Linux. The threads reported in the
> log list various sources starting the threads: from libraries we
> use, and from Tomcat's own threads like "Timer-x", "Session pool
> worker", "Level-2 Pool Sweeper", " InactivityMonitor ReadCheck".

None of those threads are "Tomcat's own". "Timer-x" is usually some
application/library use of java.util.Timer/java.util.TimerTask. I
don't recognize any of those other thread names.

Do a thread dump to find out what those threads are doing when your
application is running, and I'd be shocked to see Tomcat at the bottom
of the stack.

> Shutting down means: pressing CTRL-C in Windows or sending a kill
> signal in Linux. Maybe it is not unimported that our application
> itself uses an Executor Service Thread pool, which - at
> contextDestroyed-event - tries to shutdown the pool with a timeout
> value of 5 minutes (which is too long, I know). The log warnings
> with "Thread not stopped" messages will be written to the log after
> this timout. Then Tomcat effectively shuts down.

5 minutes is a long time. You might want to check to see why you ave
to wait that amount of time and adjust whatever processes so that they
can be interrupted if you need to take-down the server.

> My question therefore is: What can we do to shutdown Tomcat in a
> proper manner, that is: stopping all threads from thread pools? Can
> this be managed by configuration or must this be done
> programmatically?

You need to identify all of the threads that are running and arrange
to shut them all down. Most libraries have "shutdown" mechanisms that
you can use which should clean all of this up. Typically, you have to
run these "shutdown" processes in one or more ServletContextListener
objects registered with the application/container.

If you have a library which is starting threads that don't stop:

1. Upgrade to the latest version if possible
2. Read the documentation for how to shutdown those threads
   (or join the community for that library and ask)
3. Write a ServletContextListener that cleans-up that library
   (or, maybe there is already one bundled with the library)
4. If a "shutdown" process is not available for the library:
  a. Request such a process from the vendor/community
  b. Find a better-designed library and use that instead

Hope that helps,
- -chris
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/


To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to