Announcement Announcement Module
Collapse
No announcement yet.
Quartz CronTrigger firing twice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz CronTrigger firing twice

    I have several job in my applicationContext.xml - they should be fired once a hour, but the are fired twice by Quartz.
    I read this forum, but I can't understand how to solve this problem.
    This is a similar thread, but there are only theoretical solution and I need a practical solution of my problem..
    http://forum.springsource.org/showth...622#post266622
    http://forum.springsource.org/showth...b-firing-twice
    http://forum.springsource.org/showth...han-configured
    Here my applicationContext.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    
    	<bean id="ADSyncQuartzSpringJob" class="ru.croc.dms.mgik.dmsor.jobs.ActiveDirectorySync" />
    
    	<bean id="jobDetail"
    		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    		<property name="targetObject" ref="ADSyncQuartzSpringJob" />
    		<property name="targetMethod" value="execute" />
    	</bean>
    
    	<bean id="trigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="jobDetail" />
    		<property name="cronExpression" value="0 0 0 1/1 * ? *" />
    	</bean>
    
    	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    		<property name="triggers">
    			<list>
    				<ref bean="trigger" />
    				<ref bean="taskTrigger" />
    				<ref bean="clearTaskTrigger" />
    				<ref bean="attachedFilesTrigger" />
    			</list>
    		</property>
    	</bean>
    
    	<bean id="taskNotificationJob" class="ru.croc.dms.mgik.dmsor.jobs.TaskNotification" />
    
    	<bean id="taskNotifJobDetail"
    		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    		<property name="targetObject" ref="taskNotificationJob" />
    		<property name="targetMethod" value="notifyUsers" />
    	</bean>
    
    	<bean id="taskTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="taskNotifJobDetail" />
    			<property name="cronExpression" value="0 0,30 * * * ?" />
    	</bean>
    	
    	<bean id="clearTaskNotificationJob" class="ru.croc.dms.mgik.dmsor.jobs.ClearTaskNotification" />
    	
    	<bean id="clearNotificationJobDetail"
    		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    		<property name="targetObject" ref="clearTaskNotificationJob" />
    		<property name="targetMethod" value="clearTasks" />
    	</bean>
    
    	<bean id="clearTaskTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="clearNotificationJobDetail" />
    		<property name="cronExpression" value="0 55 23 * * ?" />
    	</bean>
    
    
    	<bean id="attachedFilesSyncJob" class="ru.croc.dms.mgik.dmsor.jobs.AttachedFilesSync" />
    	
    	<bean id="attachedFilesSyncDetail"
    		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    		<property name="targetObject" ref="attachedFilesSyncJob" />
    		<property name="targetMethod" value="syncAttachedFiles" />
    	</bean>
    
    	<bean id="attachedFilesTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="attachedFilesSyncDetail" />
    		<property name="cronExpression" value="0 59 23 * * ?" />
    	</bean>
    
    </beans>
    and web.xml

    Code:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    
        
        <display-name>dmsor</display-name>
        
        <description>dmsor application</description>
    
        
        <!-- Enable escaping of form submission contents -->
        <context-param>
            <param-name>defaultHtmlEscape</param-name>
            <param-value>true</param-value>
        </context-param>
        
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
        </context-param>
        
        <filter>
            <filter-name>CharacterEncodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
            <init-param>
                <param-name>forceEncoding</param-name>
                <param-value>true</param-value>
            </init-param>
        </filter>
        
        
        
        <filter>
            <filter-name>HttpMethodFilter</filter-name>
            <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
        </filter>
        
        
        
        <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
        <filter>
            <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
            <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>CharacterEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        <filter-mapping>
            <filter-name>HttpMethodFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        
        
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        <filter-mapping>
            <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        <!-- Creates the Spring Container shared by all Servlets and Filters -->
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        
        <!-- Handles Spring requests -->
        <servlet>
            <servlet-name>dmsor</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>WEB-INF/spring/webmvc-config.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        
        <servlet-mapping>
            <servlet-name>dmsor</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
        
        <session-config>
            <session-timeout>10</session-timeout>
        </session-config>
        
        <error-page>
            <exception-type>java.lang.Exception</exception-type>
            <location>/uncaughtException</location>
        </error-page>
        
        <error-page>
            <error-code>404</error-code>
            <location>/resourceNotFound</location>
        </error-page>
    </web-app>
    Thanks!

  • #2
    I think that I solve the problem. I've created for each trigger one instance of SchedulerFactoryBean.
    So I have multiple instance of SchedulerFactoryBean and working app.

    Comment


    • #3
      No, problem is still existing Can anyone help?

      Comment


      • #4
        Hi,

        i have a problem for m y quartz:
        My job run once / day at 5am after the factor job.
        i used crontrigger like this:
        "0 0 5 * * ?" but i dont know how to represente the expression after the factor jab? in the beans or others???
        Can you help me please

        Comment

        Working...
        X