错误org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin:335 - 错误调度作业:添加了没有触发器的作业必须是持久的

时间:2014-01-20 03:54:16

标签: quartz-scheduler

一切似乎与Quartz完美配合,但我在启动应用程序时得到了下面的堆栈跟踪

org.quartz.SchedulerException: Jobs added with no trigger must be durable.
at org.quartz.core.QuartzScheduler.addJob(QuartzScheduler.java:916)
at org.quartz.impl.StdScheduler.addJob(StdScheduler.java:269)
at org.quartz.xml.XMLSchedulingDataProcessor.scheduleJobs(XMLSchedulingDataProcessor.java:1069)
at org.quartz.xml.XMLSchedulingDataProcessor.processFileAndScheduleJobs(XMLSchedulingDataProcessor.java:888)
at org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin.processFile(XMLSchedulingDataProcessorPlugin.java:330)
at org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin.start(XMLSchedulingDataProcessorPlugin.java:257)
at org.quartz.plugins.SchedulerPluginWithUserTransactionSupport.start(SchedulerPluginWithUserTransactionSupport.java:144)
at org.quartz.core.QuartzScheduler.startPlugins(QuartzScheduler.java:2343)
at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:527)
at org.quartz.impl.StdScheduler.start(StdScheduler.java:143)
at org.quartz.ee.servlet.QuartzInitializerServlet.init(QuartzInitializerServlet.java:211)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

quartz-config.xml中的作业计划似乎很好,所有以编程方式安排的作业也是如此

知道造成这种情况的原因是什么?

这是配置文件,对我来说似乎是正确的

<schedule>
    <job>
        <name>ProcessLeadsJob</name>
        <group>PROCESS_LEAD_JOB_GROUP</group>
        <description>This job process the leads every 24 hours.</description>
        <job-class>ClassName</job-class>
    </job>

    <trigger>
        <cron>
            <name>processLeadsJobTrigger</name>
            <job-name>ProcessLeadsJob</job-name>
            <job-group>PROCESS_LEAD_JOB_GROUP</job-group>
            <cron-expression>0 0 00 * * ?</cron-expression>
        </cron>
    </trigger>
</schedule>

3 个答案:

答案 0 :(得分:6)

这取决于您使用的Quartz版本。

正如错误消息所示,您需要使此作业持久,即您需要添加耐久性标记,例如

<schedule>
<job>
    <name>ProcessLeadsJob</name>
    <group>PROCESS_LEAD_JOB_GROUP</group>
    <description>This job process the leads every 24 hours.</description>
    <job-class>ClassName</job-class>
    <!-- here you add the tags that are need it-->
    <durability>true</durability>
    <!--I am using quartz 2 and there is mandatory to have recover tag specified --> 
   <recover>false</recover>
</job>

<trigger>
    <cron>
        <name>processLeadsJobTrigger</name>
        <job-name>ProcessLeadsJob</job-name>
        <job-group>PROCESS_LEAD_JOB_GROUP</job-group>
        <cron-expression>0 0 00 * * ?</cron-expression>
    </cron>
</trigger>

为了知道您的quartz-config.xml文件是否正常,请根据您的石英版本检查以下架构之一:

http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd

http://www.quartz-scheduler.org/xml/job_scheduling_data_2_0.xsd

祝你好运:)

答案 1 :(得分:0)

您是否在运行期间更改了触发器中的内容?

如果是这样,请尝试将其添加到XML(标记之前)。

<pre-processing-commands>
    <delete-jobs-in-group>PROCESS_LEAD_JOB_GROUP</delete-jobs-in-group>
    <delete-triggers-in-group>PROCESS_LEAD_TRIGGER_GROUP</delete-triggers-in-group>
</pre-processing-commands>

并在触发器中添加一个组

<trigger>
    <cron>
        <name>processLeadsJobTrigger</name>
        <group>PROCESS_LEAD_TRIGGER_GROUP</group>
        <job-name>ProcessLeadsJob</job-name>
        <job-group>PROCESS_LEAD_JOB_GROUP</job-group>
        <cron-expression>0 0 00 * * ?</cron-expression>
    </cron>
</trigger>

因此,您的最终XML可能如下所示:

<pre-processing-commands>
    <delete-jobs-in-group>PROCESS_LEAD_JOB_GROUP</delete-jobs-in-group>
    <delete-triggers-in-group>PROCESS_LEAD_TRIGGER_GROUP</delete-triggers-in-group>
</pre-processing-commands>
<schedule>
    <job>
        <name>ProcessLeadsJob</name>
        <group>PROCESS_LEAD_JOB_GROUP</group>
        <description>This job process the leads every 24 hours.</description>
        <job-class>ClassName</job-class>
    </job>

    <trigger>
        <cron>
            <name>processLeadsJobTrigger</name>
            <group>PROCESS_LEAD_TRIGGER_GROUP</group>
            <job-name>ProcessLeadsJob</job-name>
            <job-group>PROCESS_LEAD_JOB_GROUP</job-group>
            <cron-expression>0 0 00 * * ?</cron-expression>
        </cron>
    </trigger>
</schedule>

希望它有效!

答案 2 :(得分:0)

我正在使用Spring上下文配置,因此下面的语法对我来说更有意义。但无论如何,你的答案解决了我的问题。

<!-- Spring Quartz -->
<bean name="createProcDateJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">

    <property name="jobClass" value="com.poc.app.web.server.scheduler.createProcDateJob" />

    <property name="jobDataAsMap">
        <map>
            <entry key="copyProdOutputTask" value-ref="copyProdOutputTask" />
        </map>
    </property>

    <property name="durability" value="true" />
</bean>