configuration of a cronTrigger (with opensymphony quartz)

l0r3nz4cc10 picture l0r3nz4cc10 · Apr 21, 2011 · Viewed 7.5k times · Source

I have a web app that has to do something every, let's say first day of every month.

It's a GWT application divided into 4 projects (if that ever matters) and I added these jars using Maven (which updated my pom.xml):

opensymphony quartz 1.6.3 commons-collections

Since I am already using Spring, I followed this tutorial (Tutorial in French)

and added what's written in the tutorial in my application-context.xml file.

At compile time, no problem, but at runtime, I have this error :

com.google.gwt.user.client.rpc.StatusCodeException: Error 500 Error creating bean with name 'schedulerFactory' defined in class path resource [application-context.xml]: Cannot resolve reference to bean 'cronTrigger' while setting bean property 'triggers' with key [0];nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cronTrigger' defined in class path resource [application-context.xml]: Error setting property values;nested exception is org.springframework.beans.PropertyBatchUpdateException;nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'cronExpression' threw exception;nested exception is java.text.ParseException: Unexpected end of expression.

Where does it come from ?

A part of my application-context.xml :

<!-- Configuration du crontrigger -->
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
        <list>
            <ref bean="cronTrigger" />
        </list>
    </property>
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail">
        <ref local="exampleJob" />
    </property>

    <!-- run every day at 6AM -->
    <property name="cronExpression" value="0 0 6 * * ?" />
</bean>
<bean id="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="fr.web.utils.ExampleJob" />
    <property name="jobDataAsMap">
        <map>
            <entry key="timeout" value="5" />
        </map>
    </property>
</bean>

Answer

jmj picture jmj · Apr 21, 2011

Issue is you have given reference in Scheduler's trigger cronTrigger which you haven't declare in the XML file.

Provide XML for more detailed answer

Update

Your cronExpression isn't seems to be valid 0 0 6 * * ? make it 0 0 6 * *  ? note the last space before ?