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

spring – 启动/停止Tomcat 6.0.29时出错

发布时间:2020-12-15 01:41:36 所属栏目:大数据 来源:网络整理
导读:我在spring中配置了一些调度程序.当我尝试启动我的Web应用程序时,它会抛出以下错误并停止.我的应用程序实际上并没有启动.我的调度程序看起来也是这样的,当我关闭tomcat时,一些石英线程没有关闭

我在spring中配置了一些调度程序.当我尝试启动我的Web应用程序时,它会抛出以下错误并停止.我的应用程序实际上并没有启动.我的调度程序看起来也是这样的,当我关闭tomcat时,一些石英线程没有关闭

堆栈跟踪:

INFO: Closing Spring root WebApplicationContext
Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak,the JDBC Driver has been forcibly unregistered.
Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/c] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@71ee88dd]) and a value of type [org.apache.cxf.bus.CXFBusImpl] (value [org.apache.cxf.bus.CXFBusImpl@409468ca]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.

我实现了监听器:

import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 import org.quartz.SchedulerException;
 import org.quartz.impl.StdSchedulerFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;


 public class QuartzServletContextListener implements ServletContextListener {

     final Logger log = LoggerFactory.getLogger(QuartzServletContextListener.class);
     public static final String QUARTZ_FACTORY_KEY =
             "org.quartz.impl.StdSchedulerFactory.KEY";
     private ServletContext ctx = null;
     private StdSchedulerFactory factory = null;

     public void contextInitialized(ServletContextEvent sce) {
         ctx = sce.getServletContext();

         try {

             factory = new StdSchedulerFactory();

             // Start the scheduler now

             factory.getScheduler().start();

             log.info("Storing QuartzScheduler Factory at"
                     + QUARTZ_FACTORY_KEY);

             ctx.setAttribute(QUARTZ_FACTORY_KEY,factory);

         } catch (Exception ex) {
             log.error("Quartz failed to initialize",ex);
         }
     }

     public void contextDestroyed(ServletContextEvent sce) {
         try {

             log.info("shutting down");
             factory.getScheduler().shutdown();
             Thread.sleep(1000);
         } catch (InterruptedException ex) {
             log.error("Quartz failed to shutdown",ex);
         } catch (SchedulerException ex) {
             log.error("Quartz failed to shutdown",ex);
         }
     }
 }

并在web.xml中添加

当我尝试使用shutdown.sh时,我仍然可以使一些线程处于活动状态并且tomcat java进程处于活动状态.

另外要提到的是,我在应用程序上下文中提到了针对不同作业的一些3到4个调度程序.

最佳答案
至于Tomcat报告的任何与Quartz相关的资源,这是因为当Quartz需要超过几毫秒来关闭其资源时,Tomcat有点过于急于寻找未释放的资源.

请参阅此处的讨论(以及简单的解决方法):

http://forums.terracotta.org/forums/posts/list/3479.page

(编辑:李大同)

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

    推荐文章
      热点阅读