停止孤儿石英调度程序

时间:2012-09-27 13:12:44

标签: linux java-ee tomcat quartz-scheduler

我为我的Tomcat服务器设置了quartz调度程序,并多次重启服务器。

调度程序开始发出类似的错误(通常是btw - 每30秒):

DEBUG org.quartz.core.QuartzSchedulerThread  - batch acquisition of 0 triggers
log4j:ERROR Error occured while converting date.
java.lang.NullPointerException
        at java.lang.System.arraycopy(Native Method)
        at java.lang.AbstractStringBuilder.getChars(AbstractStringBuilder.java:328)
        at java.lang.StringBuffer.getChars(StringBuffer.java:201)
        at org.apache.log4j.helpers.ISO8601DateFormat.format(ISO8601DateFormat.java:130)
        at java.text.DateFormat.format(DateFormat.java:316)
        at org.apache.log4j.helpers.PatternParser$DatePatternConverter.convert(PatternParser.java:444)
        at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:65)
        at org.apache.log4j.PatternLayout.format(PatternLayout.java:502)
        at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:302)
        at org.apache.log4j.WriterAppender.append(WriterAppender.java:160)
        at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
        at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
        at org.apache.log4j.Category.callAppenders(Category.java:206)
        at org.apache.log4j.Category.forcedLog(Category.java:391)
        at org.apache.log4j.Category.log(Category.java:856)
        at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:209)
        at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:268)

我认为我解决了这个问题,但现在我面临另一个问题:我重启Tomcat的前几次,我没有关闭石英调度程序。现在我将以下代码添加到我的调度程序中:

public class QuartzListener implements ServletContextListener {
    private Scheduler scheduler;

    @Override
    public void contextDestroyed(ServletContextEvent arg0) {
        if (scheduler != null) {
            try {
                scheduler.shutdown();
           } catch (SchedulerException e) {
               e.printStackTrace();
           }
       }
   }
...
}

这似乎停止了新的石英实例,但旧的石英实例继续记录相同的旧错误。所以我的问题是:如何阻止我意外忘记通过shutdown()优雅地停止的石英实例?

我在linux上运行,但是当我运行ps aux时,我从未见过石英进程/守护进程,也许我错过了一些东西。

0 个答案:

没有答案