通过jobs.xml在dropwizard-sundial中进行作业调度

时间:2015-08-04 04:06:30

标签: xml nullpointerexception dropwizard job-scheduling

我正在开发一个基于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>

关于如何解决此问题的任何想法?

1 个答案:

答案 0 :(得分:1)

查看https://github.com/timmolter/XDropWizard处的工作示例。我认为你的问题是你的<job-scheduling-data> xml元素。删除标记中的所有内容,使其仅为<job-scheduling-data>