通过 jobs.xml 在 dropwizard-sundial 中进行作业调度
Job scheduling in dropwizard-sundial thru jobs.xml
我正在开发一个基于 Dropwizard 的应用程序,并且想使用日晷作为作业调度程序。我要求作业配置在配置文件中,这样我就可以在不重新部署的情况下更改 cron 表达式。
我按照教程进行操作,但得到了 NullPointerException:
INFO [2015-08-04 02:05:01,553] org.quartz.plugins.xml.XMLSchedulingDataProcessor: Parsing XML file: jobs.xml
ERROR [2015-08-04 02:05:01,557] org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin: Error scheduling jobs: null
! java.lang.NullPointerException: null
! at java.net.URL.<init>(URL.java:525) ~[na:1.8.0_25]
! ... 53 common frames omitted
! Causing: java.net.MalformedURLException: null
! at java.net.URL.<init>(URL.java:620) ~[na:1.8.0_25]
! at java.net.URL.<init>(URL.java:483) ~[na:1.8.0_25]
! at java.net.URL.<init>(URL.java:432) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:619) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:189) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:348) ~[na:1.8.0_25]
! at org.quartz.plugins.xml.XMLSchedulingDataProcessor.process(XMLSchedulingDataProcessor.java:277) ~[FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.plugins.xml.XMLSchedulingDataProcessor.processFile(XMLSchedulingDataProcessor.java:256) ~[FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.plugins.xml.XMLSchedulingDataProcessor.processFile(XMLSchedulingDataProcessor.java:237) ~[FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin.start(XMLSchedulingDataProcessorPlugin.java:133) ~[FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.QuartzScheduler.startPlugins(QuartzScheduler.java:1102) [FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.QuartzScheduler.start(QuartzScheduler.java:211) [FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.xeiam.sundial.ee.SundialInitializerListener.contextInitialized(SundialInitializerListener.java:123) [FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
我查错了,好像找到了jobs.xml文件,但是无法解析。
我的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_2_0.xsd"
version="2.0"
>
<schedule>
<!-- job with cron trigger -->
<job>
<name>DailyOptimizationRun</name>
<job-class>com.tmrnd.swift.fl.slotoptimizer.jobs.OptimizationRun</job-class>
<concurrency-allowed>false</concurrency-allowed>
</job>
<trigger>
<cron>
<name>DailyOptimizationRun-1630-Trigger</name>
<job-name>DailyOptimizationRun</job-name>
<cron-expression>0 30 16 * * ?</cron-expression>
</cron>
</trigger>
<!--<trigger>
<cron>
<name>DailyOptimizationRun-1800-Trigger</name>
<job-name>DailyOptimizationRun</job-name>
<cron-expression>0 0 18 * * ?</cron-expression>
</cron>
</trigger>-->
</schedule>
</job-scheduling-data>
关于如何解决这个问题的任何想法?
在 https://github.com/timmolter/XDropWizard 查看一个工作示例。我认为你的问题是你的 <job-scheduling-data>
xml 元素。删除标签中的所有内容,使其只是 <job-scheduling-data>
.
我正在开发一个基于 Dropwizard 的应用程序,并且想使用日晷作为作业调度程序。我要求作业配置在配置文件中,这样我就可以在不重新部署的情况下更改 cron 表达式。 我按照教程进行操作,但得到了 NullPointerException:
INFO [2015-08-04 02:05:01,553] org.quartz.plugins.xml.XMLSchedulingDataProcessor: Parsing XML file: jobs.xml
ERROR [2015-08-04 02:05:01,557] org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin: Error scheduling jobs: null
! java.lang.NullPointerException: null
! at java.net.URL.<init>(URL.java:525) ~[na:1.8.0_25]
! ... 53 common frames omitted
! Causing: java.net.MalformedURLException: null
! at java.net.URL.<init>(URL.java:620) ~[na:1.8.0_25]
! at java.net.URL.<init>(URL.java:483) ~[na:1.8.0_25]
! at java.net.URL.<init>(URL.java:432) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:619) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:189) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243) ~[na:1.8.0_25]
! at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:348) ~[na:1.8.0_25]
! at org.quartz.plugins.xml.XMLSchedulingDataProcessor.process(XMLSchedulingDataProcessor.java:277) ~[FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.plugins.xml.XMLSchedulingDataProcessor.processFile(XMLSchedulingDataProcessor.java:256) ~[FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.plugins.xml.XMLSchedulingDataProcessor.processFile(XMLSchedulingDataProcessor.java:237) ~[FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin.start(XMLSchedulingDataProcessorPlugin.java:133) ~[FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.QuartzScheduler.startPlugins(QuartzScheduler.java:1102) [FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.quartz.QuartzScheduler.start(QuartzScheduler.java:211) [FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.xeiam.sundial.ee.SundialInitializerListener.contextInitialized(SundialInitializerListener.java:123) [FlSlotOptimizer-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
我查错了,好像找到了jobs.xml文件,但是无法解析。
我的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_2_0.xsd"
version="2.0"
>
<schedule>
<!-- job with cron trigger -->
<job>
<name>DailyOptimizationRun</name>
<job-class>com.tmrnd.swift.fl.slotoptimizer.jobs.OptimizationRun</job-class>
<concurrency-allowed>false</concurrency-allowed>
</job>
<trigger>
<cron>
<name>DailyOptimizationRun-1630-Trigger</name>
<job-name>DailyOptimizationRun</job-name>
<cron-expression>0 30 16 * * ?</cron-expression>
</cron>
</trigger>
<!--<trigger>
<cron>
<name>DailyOptimizationRun-1800-Trigger</name>
<job-name>DailyOptimizationRun</job-name>
<cron-expression>0 0 18 * * ?</cron-expression>
</cron>
</trigger>-->
</schedule>
</job-scheduling-data>
关于如何解决这个问题的任何想法?
在 https://github.com/timmolter/XDropWizard 查看一个工作示例。我认为你的问题是你的 <job-scheduling-data>
xml 元素。删除标签中的所有内容,使其只是 <job-scheduling-data>
.