Results 1 to 6 of 6

Thread: Quartz CronTrigger being fired more times than configured

  1. #1
    Join Date
    Jul 2010
    Posts
    11

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    My guess you are loading the context twice... Post your web.xml...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2010
    Posts
    11

    Default 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 at 08:38 AM.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Jul 2010
    Posts
    11

    Default

    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

  6. #6
    Join Date
    Jun 2009
    Posts
    26

    Question

    Quote 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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •