You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2018/02/02 14:33:29 UTC

Re: xxxxx have started a thread named but has failed to stop it.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Carlo,

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
     or
  b. Find a better-designed library and use that instead

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

iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlp0drgdHGNocmlzQGNo
cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFhyDw//RKkPkjs6tEdCwgaH
9ONQadWz2XLUY1uMyBD3OtfsEjqhg/96XjibQH13bBt7dC9kx9TcdnscJImCzn/u
hPOavsNtxKhtpmiuwnBEISD+vH8eOh+05vXxQNqQObe8tNMS2RXG8Qnr1zl2Iu/Z
U3vA1tWuEPulGeTVhPOmlWPJcA9b7lGvUpKTUH+ekdHQxq7t9glm1Om1WMZzj48P
3IPNxwe+oGVo3Ccwoe+UfmELMdPCHUbNiBnlof3bINyy+1Ucg3tssTgVet55w5JQ
9ItLc8t0FzIUAp/rDCqgzjWbFnhaw5udfLOCXS/4Ohx2v4lHq1MPO9iMepAh+z0/
HgHyywuawI+b5ULelzuSMkRHkBP7ISh5qs8Nk3dXGVo58r80ArR+iuLNK8EccrNT
ilIKncOW9Xoe/Y0VRmSHi+TsWSAq8FM5fe3cnzq7/g5MK5Ah6ktnD70sDMDfRN3x
06VxH6o69W0NKaIorB4dcDrVL2z2ZiJPOfKzNEuG2dkMEwot3IvBVo4PaRyNlda3
fA5+pF4t9MbMJVDf9JU+LaTubUA694Y5TYpRYs9Hc/rygZ7wcb4U50eg4s/u4IrG
SJxuMFmD65i7cZfk/m5SBTVgxhk+mRdSKXxjatDTBVSbuV1vzXU87kXcXNLu7ee+
EloBmY0axJgpLoRfxA+Wk8zpocM=
=LFFJ
-----END PGP SIGNATURE-----

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