Quartz调度程序无法启动作业

时间:2014-12-26 09:05:07

标签: java web-services maven quartz-scheduler

我想将石英调度程序用于我的Web服务,但我遇到了一些问题。当我在 Tomcat 8 页面加载项目时运行该项目但是工作似乎没有工作。我让它在maven java项目上运行,但它对maven web项目没有任何作用。也许我错过了一些重要的东西。请帮助我感谢您的所有建议。这里有例子:

Tomcat输出:

    26-Dec-2014 10:57:19.604 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 10:57:19.653 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 10:57:19.653 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 10:59:02.520 INFO [http-nio-8084-exec-7] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 10:59:03.157 INFO [http-nio-8084-exec-8] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 10:59:03.191 INFO [http-nio-8084-exec-8] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 10:59:03.191 INFO [http-nio-8084-exec-8] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 10:59:15.618 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 10:59:27.918 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 10:59:27.959 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 10:59:27.959 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 10:59:28.334 INFO [http-nio-8084-exec-9] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 10:59:28.941 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 10:59:28.975 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 10:59:28.975 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:00:59.221 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:00:59.850 INFO [http-nio-8084-exec-13] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:00:59.883 INFO [http-nio-8084-exec-13] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:00:59.883 INFO [http-nio-8084-exec-13] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:01:56.611 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:01:56.731 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:01:56.877 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:01:56.877 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:04:43.289 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:04:43.370 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:04:43.407 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:04:43.407 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:09:18.736 INFO [http-nio-8084-exec-13] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:09:18.806 INFO [http-nio-8084-exec-13] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:09:18.839 INFO [http-nio-8084-exec-13] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:09:18.839 INFO [http-nio-8084-exec-13] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:09:30.112 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:10:05.745 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:10:05.794 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:10:05.794 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:10:06.201 INFO [http-nio-8084-exec-9] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:10:06.809 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:10:06.844 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:10:06.844 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:11:36.312 INFO [http-nio-8084-exec-4] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:11:36.939 INFO [http-nio-8084-exec-3] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:11:36.973 INFO [http-nio-8084-exec-3] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:11:36.974 INFO [http-nio-8084-exec-3] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:11:39.409 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:11:52.748 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:11:52.795 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:11:52.795 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:11:53.109 INFO [http-nio-8084-exec-9] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:11:53.725 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:11:53.760 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:11:53.760 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:13:15.209 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:13:15.317 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:13:15.353 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:13:15.353 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:13:20.201 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:14:15.874 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:14:15.922 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:14:15.922 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:14:16.202 INFO [http-nio-8084-exec-9] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:14:16.825 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:14:16.867 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:14:16.867 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:17:02.436 INFO [http-nio-8084-exec-6] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:17:02.558 INFO [http-nio-8084-exec-6] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:17:02.594 INFO [http-nio-8084-exec-6] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:17:02.594 INFO [http-nio-8084-exec-6] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:19:54.434 INFO [http-nio-8084-exec-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:19:54.535 INFO [http-nio-8084-exec-6] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:19:54.634 INFO [http-nio-8084-exec-6] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:19:54.635 INFO [http-nio-8084-exec-6] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:20:12.789 INFO [http-nio-8084-exec-14] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:20:22.521 INFO [http-nio-8084-exec-11] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:20:22.570 INFO [http-nio-8084-exec-11] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:20:22.570 INFO [http-nio-8084-exec-11] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:20:33.416 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:20:47.232 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:20:47.278 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:20:47.278 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:20:47.621 INFO [http-nio-8084-exec-9] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:20:48.228 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:20:48.263 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:20:48.263 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:21:43.499 INFO [http-nio-8084-exec-7] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:21:43.634 INFO [http-nio-8084-exec-7] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:21:43.669 INFO [http-nio-8084-exec-7] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:21:43.669 INFO [http-nio-8084-exec-7] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:22:51.241 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:23:12.759 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:23:12.802 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:23:12.802 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:23:13.189 INFO [http-nio-8084-exec-9] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.
26-Dec-2014 11:23:13.798 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Initializer Servlet loaded, initializing Scheduler...
26-Dec-2014 11:23:13.848 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Scheduler has been started...
26-Dec-2014 11:23:13.848 INFO [http-nio-8084-exec-10] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
26-Dec-2014 11:24:19.413 INFO [http-nio-8084-exec-13] org.apache.catalina.core.ApplicationContext.log QuartzInitializer: Quartz Scheduler successful shutdown.

MainController.java:

public class MainController {

    public static void main(String[] args) {
        try {
            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

            scheduler.start();

            JobDetail job = newJob(TestJob.class).withIdentity("job1", "group1").build();

            Trigger trigger = newTrigger().withIdentity("trigger1", "group1").startNow().withSchedule(simpleSchedule().withIntervalInSeconds(5).repeatForever()).build();

            scheduler.scheduleJob(job, trigger);

        } catch (SchedulerException se) {
            se.printStackTrace();
        }
    }
}

TestJob.java

public class TestJob implements Job{

    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        System.out.println("I'm Test Job Running At " + new Date());
    }

}

quartz.properties

org.quartz.scheduler.skipUpdateCheck = true
org.quartz.scheduler.instanceName = MyQuartzScheduler
org.quartz.scheduler.jobFactory.class = org.quartz.simpl.SimpleJobFactory
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5

的web.xml

<?xml version="1.0" encoding="UTF-8"?>
 <web-app version="2.5"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=
        "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

     <context-param>
         <param-name>quartz:config-file</param-name>
         <param-value>quartz.properties</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:shutdown-on-unload</param-name>
         <param-value>true</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:wait-on-shutdown</param-name>
         <param-value>true</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:start-on-load</param-name>
         <param-value>true</param-value>
     </context-param>

     <listener>
         <listener-class>org.quartz.ee.servlet.QuartzInitializerListener</listener-class>
     </listener>

 </web-app>

0 个答案:

没有答案