Oracle UCP driver and tomcat: threads that cannot stop

We use the Oracle UCP driver (Oracle Universal Connection Pool) in tomcat 6. It is more or less configured, as in Orales Howto. The problem is that the driver starts many threads (Thread-0 to 57, UCP-worker-thread-1 to 24) that do not stop when the server shuts down - tomcat emits a lot of error messages like this:

It is assumed that the web application [/ xxx] started a thread named [Timer-17], but could not stop it. This is likely to create a memory leak.

Any idea how to handle this?

+6
source share
1 answer

I had the same problem and managed to fix it by adding the following code to my ServletContextListener :

 import oracle.ucp.admin.UniversalConnectionPoolManager; import oracle.ucp.admin.UniversalConnectionPoolManagerImpl; public class MyContextListener implements ServletContextListener { /* ... */ @Override public void contextDestroyed(ServletContextEvent sce) { // Your shutdown sequence here /* ... */ // Shutdown UCP if present, to avoid warnings about thread leaks UniversalConnectionPoolManager ucpManager = UniversalConnectionPoolManagerImpl.getUniversalConnectionPoolManager(); if (ucpManager != null) { String[] poolNames = ucpManager.getConnectionPoolNames(); if (poolNames != null) { for (String poolName : poolNames) { ucpManager.destroyConnectionPool(poolName); } } } } } 
+2
source

Source: https://habr.com/ru/post/910524/


All Articles