views:

229

answers:

2

I have a cronTrigger for a job "digestJob":

<bean id="digestCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail" ref="digestJob" />
    <property name="cronExpression" value="0 35 15 * * ?" />
</bean>

Here is my schedulerFactoryBean configuration:

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="digestCronTrigger" />   
            </list>
        </property>
    </bean>

The problem is, the digestCronTrigger is supposed to be fired ONCE everyday at 5:35 PM, but it is being fired TWICE at the specified time. However, when I use SimpleTrigger:

<bean id="digestTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="digestJob" />
        <property name="startDelay" value="0" />
        <property name="repeatInterval" value="10000" />
    </bean>

everything works fine and the trigger is fired exactly once every 10 seconds. Why digestCronTrigger is being fired twice? Is there something wrong with my cron expression, or is there any property that I am missing? Any help will be much appreciated.

A: 

Try this:

    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="cronTrigger" />
            </list>
        </property>
    </bean>

    <bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject" ref="actionObject" />
      <property name="targetMethod" value="actionMethod" />
    </bean>

    <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail" ref="jobDetail"/>
        <property name="cronExpression" value="0 15 17 * * ?"/>
    </bean>
StudiousJoseph
A: 

I posted same question at springsource forums where I got help to figure out the cause behind the problem: I was loading the application context twice. Later I found from this post how to avoid loading the context twice. Now things are working fine.

craftsman