加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle UCP驱动程序和tomcat:线程无法停止

发布时间:2020-12-12 16:29:39 所属栏目:百科 来源:网络整理
导读:我们在tomcat 6中使用Oracle的UCP驱动程序(Oracle通用连接池).它或多或少像在Oracles Howto中那样配置.问题是驱动程序启动了很多线程(Thread-0到57,UCP-worker-服务器关闭时没有停止的线程1到24) – tomcat发出大量错误消息,如下所示: The web application
我们在tomcat 6中使用Oracle的UCP驱动程序(Oracle通用连接池).它或多或少像在Oracles Howto中那样配置.问题是驱动程序启动了很多线程(Thread-0到57,UCP-worker-服务器关闭时没有停止的线程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);
                }
            }
        }
    }

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读