gpt4 book ai didi

Oracle UCP驱动和tomcat : threads failing to stop

转载 作者:行者123 更新时间:2023-11-28 21:47:21 59 4
gpt4 key购买 nike

我们在 tomcat 6 中使用 Oracle 的 UCP 驱动程序(Oracle Universal Connection Pool)。它的配置或多或少类似于 Oracles Howto .问题是驱动程序启动了很多线程(Thread-0 到 57,UCP-worker-thread-1 到 24),当服务器关闭时这些线程不会停止 - tomcat 会发出大量错误消息,如下所示:

The web application [/xxx] appears to have started a thread named [Timer-17] but has failed to stop it. This is very likely to create a memory leak.

知道如何处理这个吗?

最佳答案

我遇到了同样的问题,并通过在我的 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);
}
}
}
}

}

关于Oracle UCP驱动和tomcat : threads failing to stop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9671270/

59 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com