java - Quartz 调度程序、XML ValidationException

标签 java xml quartz-scheduler

我正在尝试使用 XML 文件设置 Quartz Scheduler 作业,调度程序对象正在读取 .properties 文件并查找 XML 作业定义文件。 但是我遇到了解析验证异常,并且我似乎无法根据错误找到问题所在

11:14:12.314 [localhost-startStop-1] ERROR o.q.p.x.XMLSchedulingDataProcessorPlugin - Error scheduling jobs: Encountered 2 validation exceptions.

org.quartz.xml.ValidationException:遇到 2 个验证异常。

然后

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'group'. One of '{"http://www.quartz-scheduler.org/xml/JobSchedulingData":durability, "http://www.quartz-scheduler.org/xml/JobSchedulingData":job-data-map}' is expected.

我已经定义了<durability>并且该工作不需要数据 map 。

我的 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">

    <schedule>
        <job>
            <name>MailJob</name>
            <description>Mail dispatcher job</description>
            <job-class>com.myapplication.reporting.MailJob</job-class>
            <group>MailGroup</group>
            <durability>false</durability>
        </job>

        <trigger>
            <simple>
                <name>MailTrigger</name>
                <description>Mail dispatcher job trigger, this should be set to run every 1 minute</description>
                <repeat-interval>60000</repeat-interval>
                <group>MailTriggerGroup</group>
                <job-name>MailJob</job-name>
                <job-group>mailGroup</job-group>
            </simple>
        </trigger>
    </schedule>
</job-scheduling-data>

我使用的是 Quartz 2.2.2

最佳答案

我认为问题可能在于您在 XML 中定义节点的顺序。

尝试重新排序它们,如 here

即名称/组/描述,然后是其他设置。

关于java - Quartz 调度程序、XML ValidationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36543550/

相关文章:

java - 当节点对象的状态发生变化时,如何动态更改 JTree View ?

java - Android 设备尺寸之间布局调整技术的比较

java - 在Spring MVC中,Controller是单例的,为什么我的代码是线程安全的?(Autowired HttpServeltRequest)

c# - 生成 xml 日志的日志记录组件

python lxml 3.3.5 - 加载代码时出错 - "ValueError: lxml.etree._Element has the wrong size, try recompiling"

java - Akkaquartz调度器不触发作业

.net - Quartz.NET 和 AdoJobStore

grails - 在 Grails 的 Quartz 作业中注入(inject)服务

java - 使用 charAt 时出现字符串 outOfBoundsException

java - RequestBody 参数很多时如何传递内容?