Announcement Announcement Module
Collapse
No announcement yet.
Quartz CronTrigger being fired more times than configured Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz CronTrigger being fired more times than configured

    Hi

    I have a strange problem that I have spent many hours to figure out with no success I am using Quartz Scheduler with Spring on Tomcat v5.5. I have a job "digestJob" that I am trying to invoke ONCE with a CronTrigger everyday at 3 PM. But strangely, "digestJob" is being invoked TWICE for some reason.

    Here is my cronTrigger configuration:

    Code:
    <bean id="digestCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    	    <property name="jobDetail" ref="digestJob" />
    	    <property name="cronExpression" value="0 0 15 * * ?" />
    	</bean>
    and here is my SchedulerFactoryBean configuration:

    Code:
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    	    <property name="triggers">
    	        <list>
    	            <ref bean="digestCronTrigger" />
    	        </list>
    	    </property>
    	</bean>
    An important point I noted is that when I use SimpleTriggerBean:

    Code:
    <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, trigger is fired once every 10 seconds. Why things go wrong in case of CronTriggerBean? Is there something wrong with my cronExpression or is there some other property that I am missing? Or is it a bug and there is some work around for it? Any help will be much appreciated!

    Thanks

  • #2
    My guess you are loading the context twice... Post your web.xml...

    Comment


    • #3
      Thanks for reply

      Here's my web.xml:

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4"
               xmlns="http://java.sun.com/xml/ns/j2ee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
               http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
      	<welcome-file-list>
          	<welcome-file>index.jsp</welcome-file>
        	</welcome-file-list>
      	
      	<servlet>
      		<servlet-name>springapp</servlet-name>
      		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      		<load-on-startup>1</load-on-startup>
      	</servlet>
      	<servlet-mapping>
      		<servlet-name>springapp</servlet-name>
      		<url-pattern>*.sg</url-pattern>
      	</servlet-mapping>
      	
      	
      	<filter>
      	  <filter-name>springSecurityFilterChain</filter-name>
      	  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
      	</filter>
      	<filter>
          <filter-name>OpenSessionInViewFilter</filter-name>
      	    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
      	</filter>
      	
      	<filter-mapping>
      	  <filter-name>OpenSessionInViewFilter</filter-name>
      	  <url-pattern>/*</url-pattern>
      	</filter-mapping>
      	
      	<filter-mapping>
      	  <filter-name>springSecurityFilterChain</filter-name>
      	  <url-pattern>/*</url-pattern>
      	</filter-mapping>
      	
      	<context-param>
           	<param-name>contextConfigLocation</param-name>
           	<param-value>/WEB-INF/springapp-servlet.xml</param-value>
      	</context-param>
      
      	
          <listener>
      		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      	</listener>  
      	<listener>
          	<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
        	</listener>
      	
      </web-app>
      By the way, if context had loaded twice, shouldn't the SimpleTrigger would have triggered twice every 10 seconds? ( Which is not the case, as I have mentioned in my first post! )
      Last edited by umar; Jul 20th, 2010, 08:38 AM.

      Comment


      • #4
        And as I figured, you are loading it twice...

        1) Your ContextLoaderListener is loading the springapp-servlet.xml
        2) Your DispatcherServlet is loading the by default the same.

        For the SimpleTrigger I suggest you check again because I'm 100% certain it is firing twice.

        Comment


        • #5
          Thank you Marten. The problem was exactly what you pointed out. It took me some time to figure out the solution, but now its working fine

          Comment


          • #6
            Originally posted by umar View Post
            Thank you Marten. The problem was exactly what you pointed out. It took me some time to figure out the solution, but now its working fine
            I am having this exact problem. Can you post your solution? Thank you.

            Comment

            Working...
            X