2

我想在我的小而简单的网络应用程序中使用石英。(石英 2.1.6 和 tomcat 7.0.22)。我想在不重新启动我的应用程序的情况下更改触发 cron 表达式。我将作业放在 xml 文件中quartz-jobs.xml并设置XMLSchedulingDataProcessorPluginquartz.properties

问题:当我更改内容时quartz-jobs.xml,石英检测到的文件被更改并重新加载,删除并创建新作业。我在日志文件中看到它。但是该文件的内容是旧的(与启动时相同)。

所以我在文件系统中有新版本的quartz-jobs.xml,但石英在某处获取该文件的旧版本。

文件系统是带有默认设置的普通 ext4。

那么,如何从 xml 文件中刷新石英作业和触发器?

这是我的配置:

石英属性:

org.quartz.scheduler.instanceName = SMSScheduler
org.quartz.threadPool.threadCount = 1
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
org.quartz.scheduler.skipUpdateCheck=true

org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames = quartz-jobs.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
org.quartz.plugin.jobInitializer.scanInterval = 30
org.quartz.plugin.jobInitializer.wrapInUserTransaction = false

石英-jobs.xml

<?xml version='1.0' encoding='utf-8'?>
<job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
                     version="1.8">

    <pre-processing-commands>
        <delete-jobs-in-group>REPORT_GROUP</delete-jobs-in-group>
        <delete-triggers-in-group>REPORT_TRIGGER_GROUP</delete-triggers-in-group>
    </pre-processing-commands>
    <schedule>
        <job>
            <name>report-job</name>
            <group>REPORT_GROUP</group>
            <description>Create report</description>
            <job-class>com.company.quartz.ReportJob</job-class>
        </job>
        <trigger>
            <cron>
                <name>every-day-trigger</name>
                <group>REPORT_TRIGGER_GROUP</group>
                <job-name>report-job</job-name>

                <job-group>REPORT_GROUP</job-group>
                <!-- trigger every minute -->
                <cron-expression>0 * * * * ?</cron-expression>
            </cron>
        </trigger>
    </schedule>
</job-scheduling-data>

报告作业.java

package com.company.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

public class ReportJob implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
            System.out.println("test!");
    }
}

日志,您可以在其中查看检查间隔和正在运行的作业:

2012-11-22 11:47:20,169 INFO [pool-2-thread-1] [QuartzInitializerListener.java:contextInitialized:147] Quartz Initializer Servlet loaded, initializing Scheduler...
2012-11-22 11:47:20,223 INFO [pool-2-thread-1] [StdSchedulerFactory.java:instantiate:1157] Using default implementation for ThreadExecutor
2012-11-22 11:47:20,261 INFO [pool-2-thread-1] [SchedulerSignalerImpl.java:<init>:61] Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
2012-11-22 11:47:20,261 INFO [pool-2-thread-1] [QuartzScheduler.java:<init>:243] Quartz Scheduler v.2.1.6 created.
2012-11-22 11:47:20,263 INFO [pool-2-thread-1] [XMLSchedulingDataProcessorPlugin.java:initialize:202] Registering Quartz Job Initialization Plug-in.
2012-11-22 11:47:20,264 INFO [pool-2-thread-1] [RAMJobStore.java:initialize:154] RAMJobStore initialized.
2012-11-22 11:47:20,266 INFO [pool-2-thread-1] [QuartzScheduler.java:initialize:268] Scheduler meta-data: Quartz Scheduler (v2.1.6) 'SMSScheduler' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 1 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

2012-11-22 11:47:20,266 INFO [pool-2-thread-1] [StdSchedulerFactory.java:instantiate:1306] Quartz scheduler 'SMSScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
2012-11-22 11:47:20,266 INFO [pool-2-thread-1] [StdSchedulerFactory.java:instantiate:1310] Quartz scheduler version: 2.1.6
2012-11-22 11:47:20,275 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessorPlugin.java:start:254] Scheduled file scan job for data file: quartz-jobs.xml, at interval: 10000
2012-11-22 11:47:20,280 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:resolveSchemaSource:239] Utilizing schema packaged in local quartz distribution jar.
2012-11-22 11:47:20,283 INFO [pool-2-thread-1] [XMLSchedulingDataProcessor.java:processFile:498] Parsing XML file: quartz-jobs.xml with systemId: quartz-jobs.xml
2012-11-22 11:47:20,358 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:549] Found 1 delete job group commands.
2012-11-22 11:47:20,365 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:563] Found 1 delete trigger group commands.
2012-11-22 11:47:20,367 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:577] Found 0 delete job commands.
2012-11-22 11:47:20,368 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:594] Found 0 delete trigger commands.
2012-11-22 11:47:20,375 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:614] Directive 'overwrite-existing-data' not specified, defaulting to true
2012-11-22 11:47:20,377 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:624] Directive 'ignore-duplicates' not specified, defaulting to false
2012-11-22 11:47:20,378 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:638] Found 1 job definitions.
2012-11-22 11:47:20,398 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:674] Parsed job definition: JobDetail 'REPORT_GROUP.report-job':  jobClass: 'com.company.quartz.ReportJob concurrentExectionDisallowed: false persistJobDataAfterExecution: false isDurable: false requestsRecovers: false
2012-11-22 11:47:20,407 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:686] Found 1 trigger definitions.
2012-11-22 11:47:20,451 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:817] Parsed trigger definition: Trigger 'REPORT_TRIGGER_GROUP.every-day-trigger':  triggerClass: 'org.quartz.impl.triggers.CronTriggerImpl calendar: 'null' misfireInstruction: 0 nextFireTime: null
2012-11-22 11:47:20,457 INFO [pool-2-thread-1] [XMLSchedulingDataProcessor.java:executePreProcessCommands:962] Deleting all jobs in group: REPORT_GROUP
2012-11-22 11:47:20,461 INFO [pool-2-thread-1] [XMLSchedulingDataProcessor.java:executePreProcessCommands:983] Deleting all triggers in group: REPORT_TRIGGER_GROUP
2012-11-22 11:47:20,461 INFO [pool-2-thread-1] [XMLSchedulingDataProcessor.java:scheduleJobs:1021] Adding 1 jobs, 1 triggers.
2012-11-22 11:47:20,461 INFO [pool-2-thread-1] [XMLSchedulingDataProcessor.java:scheduleJobs:1046] Adding job: REPORT_GROUP.report-job
2012-11-22 11:47:20,462 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:scheduleJobs:1107] Scheduling job: REPORT_GROUP.report-job with trigger: REPORT_TRIGGER_GROUP.every-day-trigger
2012-11-22 11:47:20,471 INFO [pool-2-thread-1] [QuartzScheduler.java:start:534] Scheduler SMSScheduler_$_NON_CLUSTERED started.
2012-11-22 11:47:20,472 INFO [pool-2-thread-1] [QuartzInitializerListener.java:contextInitialized:199] Scheduler has been started...
2012-11-22 11:47:20,472 INFO [pool-2-thread-1] [QuartzInitializerListener.java:contextInitialized:217] Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
2012-11-22 11:47:20,481 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers
2012-11-22 11:47:20,493 DEBUG [SMSScheduler_QuartzSchedulerThread] [SimpleJobFactory.java:newJob:51] Producing instance of Job 'JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml', class=org.quartz.jobs.FileScanJob
2012-11-22 11:47:20,516 DEBUG [SMSScheduler_Worker-1] [JobRunShell.java:run:212] Calling execute on job JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml
2012-11-22 11:47:20,517 DEBUG [SMSScheduler_Worker-1] [FileScanJob.java:execute:138] File 'quartz-jobs.xml' unchanged.
2012-11-22 11:47:20,517 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers
2012-11-22 11:47:30,272 DEBUG [SMSScheduler_QuartzSchedulerThread] [SimpleJobFactory.java:newJob:51] Producing instance of Job 'JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml', class=org.quartz.jobs.FileScanJob
2012-11-22 11:47:30,272 DEBUG [SMSScheduler_Worker-1] [JobRunShell.java:run:212] Calling execute on job JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml
2012-11-22 11:47:30,272 DEBUG [SMSScheduler_Worker-1] [FileScanJob.java:execute:138] File 'quartz-jobs.xml' unchanged.
2012-11-22 11:47:30,273 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers
2012-11-22 11:47:40,271 DEBUG [SMSScheduler_QuartzSchedulerThread] [SimpleJobFactory.java:newJob:51] Producing instance of Job 'JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml', class=org.quartz.jobs.FileScanJob
2012-11-22 11:47:40,272 DEBUG [SMSScheduler_Worker-1] [JobRunShell.java:run:212] Calling execute on job JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml
2012-11-22 11:47:40,272 DEBUG [SMSScheduler_Worker-1] [FileScanJob.java:execute:138] File 'quartz-jobs.xml' unchanged.
2012-11-22 11:47:40,272 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers
2012-11-22 11:47:50,271 DEBUG [SMSScheduler_QuartzSchedulerThread] [SimpleJobFactory.java:newJob:51] Producing instance of Job 'JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml', class=org.quartz.jobs.FileScanJob
2012-11-22 11:47:50,271 DEBUG [SMSScheduler_Worker-1] [JobRunShell.java:run:212] Calling execute on job JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml
2012-11-22 11:47:50,271 DEBUG [SMSScheduler_Worker-1] [FileScanJob.java:execute:138] File 'quartz-jobs.xml' unchanged.
2012-11-22 11:47:50,273 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers
2012-11-22 11:48:00,001 DEBUG [SMSScheduler_QuartzSchedulerThread] [SimpleJobFactory.java:newJob:51] Producing instance of Job 'REPORT_GROUP.report-job', class=com.company.quartz.ReportJob
2012-11-22 11:48:00,003 DEBUG [SMSScheduler_Worker-1] [JobRunShell.java:run:212] Calling execute on job REPORT_GROUP.report-job
2012-11-22 11:48:00,003 ERROR [SMSScheduler_Worker-1] [ReportJob.java:execute:31] test
2012-11-22 11:48:00,289 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers
2012-11-22 11:48:00,290 DEBUG [SMSScheduler_QuartzSchedulerThread] [SimpleJobFactory.java:newJob:51] Producing instance of Job 'JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml', class=org.quartz.jobs.FileScanJob
2012-11-22 11:48:00,290 DEBUG [SMSScheduler_Worker-1] [JobRunShell.java:run:212] Calling execute on job JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml
2012-11-22 11:48:00,290 DEBUG [SMSScheduler_Worker-1] [FileScanJob.java:execute:138] File 'quartz-jobs.xml' unchanged.
2012-11-22 11:48:00,290 DEBUG [SMSScheduler_QuartzSchedulerThread] 

接下来我更改内容quartz-jobs.xml,使其无效,所以我希望看到 xml 解析器错误,但没有任何变化:

2012-11-22 11:51:20,280 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers
2012-11-22 11:51:30,271 DEBUG [SMSScheduler_QuartzSchedulerThread] [SimpleJobFactory.java:newJob:51] Producing instance of Job 'JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml', class=org.quartz.jobs.FileScanJob
2012-11-22 11:51:30,272 DEBUG [SMSScheduler_Worker-1] [JobRunShell.java:run:212] Calling execute on job JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml
2012-11-22 11:51:30,272 INFO [SMSScheduler_Worker-1] [FileScanJob.java:execute:135] File 'quartz-jobs.xml' updated, notifying listener.
2012-11-22 11:51:30,273 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:resolveSchemaSource:239] Utilizing schema packaged in local quartz distribution jar.
2012-11-22 11:51:30,277 INFO [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:processFile:498] Parsing XML file: quartz-jobs.xml with systemId: quartz-jobs.xml
2012-11-22 11:51:30,306 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:549] Found 1 delete job group commands.
2012-11-22 11:51:30,308 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:563] Found 1 delete trigger group commands.
2012-11-22 11:51:30,310 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:577] Found 0 delete job commands.
2012-11-22 11:51:30,312 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:594] Found 0 delete trigger commands.
2012-11-22 11:51:30,313 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:614] Directive 'overwrite-existing-data' not specified, defaulting to true
2012-11-22 11:51:30,314 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:624] Directive 'ignore-duplicates' not specified, defaulting to false
2012-11-22 11:51:30,315 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:638] Found 1 job definitions.
2012-11-22 11:51:30,327 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:674] Parsed job definition: JobDetail 'REPORT_GROUP.report-job':  jobClass: 'com.company.quartz.ReportJob concurrentExectionDisallowed: false persistJobDataAfterExecution: false isDurable: false requestsRecovers: false
2012-11-22 11:51:30,328 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:686] Found 1 trigger definitions.
2012-11-22 11:51:30,351 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:process:817] Parsed trigger definition: Trigger 'REPORT_TRIGGER_GROUP.every-day-trigger':  triggerClass: 'org.quartz.impl.triggers.CronTriggerImpl calendar: 'null' misfireInstruction: 0 nextFireTime: null
2012-11-22 11:51:30,351 INFO [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:executePreProcessCommands:962] Deleting all jobs in group: REPORT_GROUP
2012-11-22 11:51:30,352 INFO [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:executePreProcessCommands:983] Deleting all triggers in group: REPORT_TRIGGER_GROUP
2012-11-22 11:51:30,352 INFO [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:scheduleJobs:1021] Adding 1 jobs, 1 triggers.
2012-11-22 11:51:30,352 INFO [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:scheduleJobs:1046] Adding job: REPORT_GROUP.report-job
2012-11-22 11:51:30,352 DEBUG [SMSScheduler_Worker-1] [XMLSchedulingDataProcessor.java:scheduleJobs:1107] Scheduling job: REPORT_GROUP.report-job with trigger: REPORT_TRIGGER_GROUP.every-day-trigger
2012-11-22 11:51:30,353 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers

之后我重新启动tomcat,错误就在这里!但是为什么重启后才出现呢?

2012-11-22 12:03:38,740 INFO [pool-2-thread-1] [QuartzScheduler.java:<init>:243] Quartz Scheduler v.2.1.6 created.
2012-11-22 12:03:38,741 INFO [pool-2-thread-1] [XMLSchedulingDataProcessorPlugin.java:initialize:202] Registering Quartz Job Initialization Plug-in.
2012-11-22 12:03:38,743 INFO [pool-2-thread-1] [RAMJobStore.java:initialize:154] RAMJobStore initialized.
2012-11-22 12:03:38,744 INFO [pool-2-thread-1] [QuartzScheduler.java:initialize:268] Scheduler meta-data: Quartz Scheduler (v2.1.6) 'SMSScheduler' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 1 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

2012-11-22 12:03:38,744 INFO [pool-2-thread-1] [StdSchedulerFactory.java:instantiate:1306] Quartz scheduler 'SMSScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
2012-11-22 12:03:38,744 INFO [pool-2-thread-1] [StdSchedulerFactory.java:instantiate:1310] Quartz scheduler version: 2.1.6
2012-11-22 12:03:38,753 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessorPlugin.java:start:254] Scheduled file scan job for data file: quartz-jobs.xml, at interval: 10000
2012-11-22 12:03:38,757 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:resolveSchemaSource:239] Utilizing schema packaged in local quartz distribution jar.
2012-11-22 12:03:38,761 INFO [pool-2-thread-1] [XMLSchedulingDataProcessor.java:processFile:498] Parsing XML file: quartz-jobs.xml with systemId: quartz-jobs.xml
2012-11-22 12:03:38,837 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:549] Found 1 delete job group commands.
2012-11-22 12:03:38,838 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:563] Found 1 delete trigger group commands.
2012-11-22 12:03:38,847 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:577] Found 0 delete job commands.
2012-11-22 12:03:38,848 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:594] Found 0 delete trigger commands.
2012-11-22 12:03:38,850 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:614] Directive 'overwrite-existing-data' not specified, defaulting to true
2012-11-22 12:03:38,851 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:624] Directive 'ignore-duplicates' not specified, defaulting to false
2012-11-22 12:03:38,861 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:638] Found 1 job definitions.
2012-11-22 12:03:38,880 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:674] Parsed job definition: JobDetail 'REPORT_GROUP.report-job':  jobClass: 'com.company.quartz.ReportJob concurrentExectionDisallowed: false persistJobDataAfterExecution: false isDurable: false requestsRecovers: false
2012-11-22 12:03:38,882 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:686] Found 1 trigger definitions.
2012-11-22 12:03:38,920 DEBUG [pool-2-thread-1] [XMLSchedulingDataProcessor.java:process:817] Parsed trigger definition: Trigger 'REPORT_TRIGGER_GROUP.every-day-trigger':  triggerClass: 'org.quartz.impl.triggers.CronTriggerImpl calendar: 'null' misfireInstruction: 0 nextFireTime: null
2012-11-22 12:03:38,938 ERROR [pool-2-thread-1] [XMLSchedulingDataProcessorPlugin.java:processFile:335] Error scheduling jobs: Encountered 1 validation exceptions.
org.quartz.xml.ValidationException: Encountered 1 validation exceptions.
    at org.quartz.xml.XMLSchedulingDataProcessor.maybeThrowValidationException(XMLSchedulingDataProcessor.java:1256) ~[quartz-2.1.6.jar:na]
    at org.quartz.xml.XMLSchedulingDataProcessor.processFile(XMLSchedulingDataProcessor.java:505) ~[quartz-2.1.6.jar:na]
    at org.quartz.xml.XMLSchedulingDataProcessor.processFileAndScheduleJobs(XMLSchedulingDataProcessor.java:886) ~[quartz-2.1.6.jar:na]
    at org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin.processFile(XMLSchedulingDataProcessorPlugin.java:330) [quartz-2.1.6.jar:na]
    at org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin.start(XMLSchedulingDataProcessorPlugin.java:257) [quartz-2.1.6.jar:na]
    at org.quartz.plugins.SchedulerPluginWithUserTransactionSupport.start(SchedulerPluginWithUserTransactionSupport.java:144) [quartz-2.1.6.jar:na]
    at org.quartz.core.QuartzScheduler.startPlugins(QuartzScheduler.java:2343) [quartz-2.1.6.jar:na]
    at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:527) [quartz-2.1.6.jar:na]
    at org.quartz.impl.StdScheduler.start(StdScheduler.java:143) [quartz-2.1.6.jar:na]
    at org.quartz.ee.servlet.QuartzInitializerListener.contextInitialized(QuartzInitializerListener.java:198) [quartz-2.1.6.jar:na]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779) [catalina.jar:7.0.27]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273) [catalina.jar:7.0.27]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.27]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895) [catalina.jar:7.0.27]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871) [catalina.jar:7.0.27]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615) [catalina.jar:7.0.27]
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099) [catalina.jar:7.0.27]
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621) [catalina.jar:7.0.27]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_32]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_32]
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_32]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_32]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_32]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_32]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'cron' cannot have character [children], because the type's content type is element-only.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:423) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3188) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidComplexType(XMLSchemaValidator.java:3151) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3111) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3013) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2156) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:824) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2939) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:232) ~[na:1.6.0_32]
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284) ~[na:1.6.0_32]
    at org.quartz.xml.XMLSchedulingDataProcessor.process(XMLSchedulingDataProcessor.java:539) ~[quartz-2.1.6.jar:na]
    at org.quartz.xml.XMLSchedulingDataProcessor.processFile(XMLSchedulingDataProcessor.java:503) ~[quartz-2.1.6.jar:na]
    ... 22 common frames omitted
2012-11-22 12:03:38,947 INFO [pool-2-thread-1] [QuartzScheduler.java:start:534] Scheduler SMSScheduler_$_NON_CLUSTERED started.
2012-11-22 12:03:38,947 INFO [pool-2-thread-1] [QuartzInitializerListener.java:contextInitialized:199] Scheduler has been started...
2012-11-22 12:03:38,947 INFO [pool-2-thread-1] [QuartzInitializerListener.java:contextInitialized:217] Storing the Quartz Scheduler Factory in the servlet context at key: org.quartz.impl.StdSchedulerFactory.KEY
2012-11-22 12:03:38,950 DEBUG [SMSScheduler_QuartzSchedulerThread] [QuartzSchedulerThread.java:run:268] batch acquisition of 1 triggers
2012-11-22 12:03:39,002 DEBUG [SMSScheduler_QuartzSchedulerThread] [SimpleJobFactory.java:newJob:51] Producing instance of Job 'JobSchedulingDataLoaderPlugin.JobSchedulingDataLoaderPlugin_jobInitializer_quartz-jobs_xml', class=org.quartz.jobs.FileScanJob

编辑:报告给兵马俑https://jira.terracotta.org/jira/browse/QTZ-334

4

2 回答 2

5

您应该尝试指定quartz-jobs.xml文件的绝对路径以避免tomcat 不会在webapp 上下文中重新加载文件的问题,即使它们被更改。

于 2012-11-26T15:07:47.947 回答
2

我们为我们的业务需求构建了一个小型 java 项目,其中使用了上面提到的相同配置的 quartz.properties 和 quartz_jobs.xml,但没有 Tomcat(Java 应用程序项目)。

即使在小程序中,启动Java类(scheduler.start())后,修改quartz-jobs.xml也没有触发基于表达式变化的cron。

为了解决这个问题,我在quartz.properties 中提供了绝对路径,然后调度器Factory 拾取了cron 表达式的变化。

于 2014-01-31T17:07:24.103 回答