Comodore Panamo
Comodore Panamo

Reputation: 61

Spring Quartz-Scheduler keep making requests more than once

I have a Java web application with a Quartz-Scheduler that is triggered once a day. But the problem is that he is keep requesting the same trigger many times at once, and somewtimes it says that there are multiple instances of id "cronTrigger".

Caused by: org.xml.sax.SAXParseException; lineNumber: 50; columnNumber: 90; cvc-id.2: There are multiple occurrences of ID value 'cronTrigger'.

I mean:

Trigger started .....
Trigger started .....
Trigger started .....
Trigger started .....

Trigger started .....
Trigger started .....
Trigger started .....
Trigger started .....

instead of this:

Trigger started .....

Trigger started .....

Trigger started .....

Trigger started .....

Trigger started .....

etc.

My applicationContext.xml looks like this:

<bean name="schedulerTask" class="com.myapp.struts.triggers.SchedulerTask"></bean>

<bean id="schedulerJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="schedulerTask" />
    <property name="targetMethod" value="execute" />
</bean>

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="schedulerJob" />
    <property name="cronExpression" value="0/10 * * * * ?"/> //for test: scheduler is triggered each 10 seconds
</bean>

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

I can't find where the problem come from, maybe you guys can help me ..

Upvotes: 1

Views: 1113

Answers (1)

Comodore Panamo
Comodore Panamo

Reputation: 61

I have added new applicationContext-scheduler.xml file, then added it in web.xml as:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/applicationContext.xml,
        /WEB-INF/applicationContext-scheduler.xml
    </param-value>
</context-param>

the only solution that works well.

Upvotes: 1

Related Questions