Quartz Scheduler, XML ValidationException - java

I'm trying to setup a Quartz Scheduler job using an XML file, the scheduler object is reading the .properties file and finds the XML job definition file.
however I am getting a parsing validation exception and I can't seem to be able to find what's wrong based on the error
11:14:12.314 [localhost-startStop-1] ERROR o.q.p.x.XMLSchedulingDataProcessorPlugin - Error scheduling jobs: Encountered 2 validation exceptions.
org.quartz.xml.ValidationException: Encountered 2 validation exceptions.
and then
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.
I have already defined <durability> and the job doesn't require a data map.
My XML is
<?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>
I am using Quartz 2.2.2

I suppose the problem may be in the order in which you define nodes in your XML.
Try reorder them like here
I.e. name/group/description then other settings.

It appears the order of the XML elements is important for the parser, using the Netbeans XML validation feature I edited the XML file and it's now working fine
<?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>
<group>MailGroup</group>
<description>Mail dispatcher job</description>
<job-class>com.myapplication.reporter.MailJob</job-class>
</job>
<trigger>
<simple>
<name>MailTrigger</name>
<description>Mail dispatcher job trigger, this should be set to run every 1 minute</description>
<job-name>MailJob</job-name>
<job-group>MailGroup</job-group>
<repeat-count>0</repeat-count>
<repeat-interval>60000</repeat-interval>
</simple>
</trigger>
</schedule>
</job-scheduling-data>

Related

org.xml.sax.SAXParseException: Failed to read schema document mule-mongo.xsd in mule-domain-config

I migrate resources from different Mule Projects to one Mule Domain Project (which should be used by all the other Mule Projects). Everything works fine except the configuration for the mongodb. If I start everything and the domain starts initialization I get the following error:
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd'
See the corresponding mule-domain-config.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<mule-domain
xmlns="http://www.mulesoft.org/schema/mule/domain"
xmlns:mule="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/domain http://www.mulesoft.org/schema/mule/domain/current/mule-domain.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<!-- configure here resource to be shared within the domain -->
<context:property-placeholder location="${mule.env}.properties "/>
<mongo:config name="mongoconfig" host="${mongo.host}" port="${mongo.port}" database="${mongo.database}" doc:name="Mongo DB" connectTimeout="5000" connectionsPerHost="1" autoConnectRetry="true" threadsAllowedToBlockForConnectionMultiplier="50" username="${mongo.username}">
<mongo:connection-pooling-profile maxActive="150" initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW" maxIdle="50" ></mongo:connection-pooling-profile>
<mule:reconnect frequency="1000"></mule:reconnect>
</mongo:config>
<http:listener-config name="HTTP_Listener_Configuration" host="${http.host}" port="${http.port}" doc:name="HTTP Listener Configuration"/>
</mule-domain>
My first idea was, that I need to add the mule-module-mongo dependency to the pom.xml. But this didn't change anything.
In the Mule Projects the same configuration, with the same schema declaration work just fine. Do I miss something here?
The problem is that Mongo is not supported as a shared resource so you cannot define it's config at the domain level.
You can find more information on what connectors are supported here.
HTH

How to store timestamp in Maven Surefire generated report.xml?

Is there a way, to instruct Maven Surefire, to save the test starting time of each JUnit Test Case in the report xml file?
I expect that the report should look a bit like this:
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="com.chris.testcases.Timestamp" time="1,962.965" tests="1" errors="0" skipped="0" failures="0">
<properties>
<property ...>
</properties>
<testcase
name="Timestampfilter"
classname="com.chris.testcases.Timestamp"
time="1,339.383" <-- this is the already existing execution time
--> timestamp="2015-03-11 16:44:05" /> <-- this is the NEW attribute I need
...
</testsuite>
Background: I need this paramter for future processing in this xml, and just writing the timestamp in the "normal" logfile/output is no solution.
I am using: Maven 3.2.5 with Surefire-Plugin 2.18.1.
Update: I found an similar question here: https://jira.codehaus.org/browse/SUREFIRE-681

How to add a property into an xml?

I´ve a quartz-config file and I want to load my cron expression from my property file, here is the code:
<?xml version='1.0' encoding='utf-8'?>
<job-scheduling-data version="1.8"
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">
<properties>
<property url="file:///C:/apps/Labels/resources/ftp.properties"></property>
</properties>
<schedule>
<job>
<name>DevolucionesShippingJob</name>
<group>DevolucionesShippingJob</group>
<description>Retrieve FTP jobs procesed files from BIDS</description>
<job-class>com.quartz.DevolucionesShippingJob</job-class>
</job>
<trigger>
<cron>
<name>DevolucionesShippingTrigger</name>
<group>DEFAULT</group>
<job-name>DevolucionesShippingJob</job-name>
<job-group>DevolucionesShippingJob</job-group>
<cron-expression>0 07 19 * * ?</cron-expression>
</cron>
</trigger>
</schedule>
</job-scheduling-data>
The problem is that the eclipse parse marks an error in the line that has
How can I import a property file into my xml?
Thanks in advance.
It has been a while since I used Quartz but I do not recall seeing this done before. Also, if I'm looking at the referenced schema correctly, the properties element is not valid (hence Eclipse showing an error). In short, I don't think you can do this.

Spring Framework: The document type declaration for root element type "beans" must end with '>'

This is my spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans SYSTEM "http://www.springframework.org/dtd/spring-beans-2.0.dtd" PUBLIC "-//SPRING//DTD BEAN 2.0//EN">
<beans>
<bean id="data" class="com.blah.tests.DataProviderClass" />
<bean id="wdcm" class="com.blah.tests.WebDriverCustomMethods"/>
</beans>
When I run my application test, this is the error I get:
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 2 in XML document from class path resource [spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException;
lineNumber: 2; columnNumber: 82; The document type declaration for root element type "beans" must end with '>'.
Im using Spring 3.0.7
Try this...
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" >
<bean id="data" class="com.blah.tests.DataProviderClass" />
<bean id="wdcm" class="com.blah.tests.WebDriverCustomMethods"/>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- <bean/> definitions here -->
</beans>
Actually the DTD style is still fully supported:
http://static.springsource.org/spring/docs/3.0.x/reference/xsd-config.html
DTD support?
Authoring Spring configuration files using the older DTD style is still fully supported.
Nothing will break if you forego the use of the new XML Schema-based approach to authoring >Spring XML configuration files. All that you lose out on is the opportunity to have more >succinct and clearer configuration. Regardless of whether the XML configuration is DTD- or >Schema-based, in the end it all boils down to the same object model in the container (namely >one or more BeanDefinition instances).
according to your issue, this is maybe caused by the network, did you try to open http://www.springframework.org/dtd/spring-beans-2.0.dtd directly in the browser?(I think you will get error when you open http://www.springframework.org/dtd/spring-beans-2.0.dtd directly in the browser.)

ActiveMQ configuration and Spring Expression Language (SpEL)

I have to start multiple instances (separate JVMs) of this one service on the same machine which has a persistent embedded broker. All config files are pre-generated and have their variable substitutions done on compilation way before the services start. I'm having problems with several instances trying to get a lock of AMQ data directory and KahaDB, obviously the 1st instance successfully gets the lock and the rest keep on trying unsuccessfully.
I need to set something like this:
. . .
<amq:broker dataDirectory="${activemq.directory}/data" id="broker" persistent="true" useJmx="false" >
. . .
I tried PropertyPlaceholderConfigurer but as I understand it loads the properties from a file specified in Spring configuration and at the time it starts up is too late already. I'm trying to use Spring Expression Language so I end up with something like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd">
<!-- Embedded ActiveMQ Broker -->
<amq:broker dataDirectory="#{systemProperties['activemq.directory']}/data" id="broker" persistent="true" useJmx="false" >
...
I pass on the command line
-Dactivemq.directory=<my-directory>
On the log I see
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '{systemProperties['activemq.directory']}/data' is defined
Does it seem like I'm missing something with AMQ and Spring3 SpEL? Is there some other solution to that does the same think I may be missing?
1. A very nasty, (but at least working) solution is to put a white space to the beginning if you want to use PropertyPlaceholderConfigurer.
<amq:broker useJmx="false" persistent="false">
<amq:transportConnectors>
<amq:transportConnector uri=" #{myconf.getConfigurationValue('JMS_URI')}" />
</amq:transportConnectors>
</amq:broker>
myconf.properties: JMS_URI=tcp://localhost:0?daemon=false
2. What is also interesting that if you explicitly set at least the protocol, then it also works:
<amq:broker useJmx="false" persistent="false">
<amq:transportConnectors>
<amq:transportConnector uri="tcp://#{myconf.getConfigurationValue('JMS_URI')}" />
</amq:transportConnectors>
</amq:broker>
myconf.properties: JMS_URI=localhost:0?daemon=false
I ended up using simply the good old PropertyPlaceholderConfigurer and removing the SpEL notation, it works like a charm.

Categories

Resources