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

前端之家收集整理的这篇文章主要介绍了spring – 启动/停止Tomcat 6.0.29时出错前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

  1. factorybean" destroy-method="destroy">
  2. factorybean">

堆栈跟踪:

  1. INFO: Closing Spring root WebApplicationContext
  2. Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
  3. 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.
  4. Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  5. 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.
  6. Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  7. 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.
  8. Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  9. 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.
  10. Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  11. 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.
  12. Mar 31,2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
  13. 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.

我实现了监听器:

  1. import javax.servlet.ServletContext;
  2. import javax.servlet.ServletContextEvent;
  3. import javax.servlet.ServletContextListener;
  4. import org.quartz.SchedulerException;
  5. import org.quartz.impl.StdSchedulerFactory;
  6. import org.slf4j.Logger;
  7. import org.slf4j.LoggerFactory;
  8. public class QuartzServletContextListener implements ServletContextListener {
  9. final Logger log = LoggerFactory.getLogger(QuartzServletContextListener.class);
  10. public static final String QUARTZ_FACTORY_KEY =
  11. "org.quartz.impl.StdSchedulerFactory.KEY";
  12. private ServletContext ctx = null;
  13. private StdSchedulerFactory factory = null;
  14. public void contextInitialized(ServletContextEvent sce) {
  15. ctx = sce.getServletContext();
  16. try {
  17. factory = new StdSchedulerFactory();
  18. // Start the scheduler now
  19. factory.getScheduler().start();
  20. log.info("Storing QuartzScheduler Factory at"
  21. + QUARTZ_FACTORY_KEY);
  22. ctx.setAttribute(QUARTZ_FACTORY_KEY,factory);
  23. } catch (Exception ex) {
  24. log.error("Quartz Failed to initialize",ex);
  25. }
  26. }
  27. public void contextDestroyed(ServletContextEvent sce) {
  28. try {
  29. log.info("shutting down");
  30. factory.getScheduler().shutdown();
  31. Thread.sleep(1000);
  32. } catch (InterruptedException ex) {
  33. log.error("Quartz Failed to shutdown",ex);
  34. } catch (SchedulerException ex) {
  35. log.error("Quartz Failed to shutdown",ex);
  36. }
  37. }
  38. }

并在web.xml中添加

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

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

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

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

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

猜你在找的Spring相关文章