Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Quartz jobs scheduled twice

  1. #11

    Default

    I also have a TaskExecutor defined, but that shouldn't do anything to quartz?

    Code:
    <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    	  <property name="corePoolSize" value="5"/>
    	  <property name="maxPoolSize" value="10"/>
    </bean>

  2. #12

    Default

    Interesting...

    From the logs, the job fires ONCE on my development machine. My development machine is windows and has tomcat 5.5.17 installed. I start tomcat using sysdeo's plug in.

    From the logs, the job fires TWICE on the production server. The production server is RHEL4 with the tomcat version 5.5.17.

    I will have to investigate. The only difference off the top of my head is the production is set as the root context.

    adam

  3. #13
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Sorry I haven't posted back I missed the responses. I guess it must be something in the environment then. I'm still not sure what would cause this. If it's exactly the same web app you would expect it to behave in the same way. If you do make any headway on this it would be great if you could post back!

  4. #14

    Default fixed itself?

    Assuming the logs actually portray an accurate picture of what's going on, then it appears to have fixed itself!?

    I certainly wasn't doing any work past 11 on this day...Note how the logs at the start show the job triggering twice at the same time, then at the end just once - from then on!

    Code:
    2007-04-24 23:05:00,015 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  23:05:00 24/Apr/2007
    2007-04-24 23:05:00,017 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  23:05:00 24/Apr/2007
    2007-04-24 23:05:00,072 INFO [com.service.threads.TaskJob] - handling task: user_event_type_utc_version_processing 2, 0, 3, 2007-04-23T13:30:00.000+01:00, 992, true
    2007-04-24 23:05:00,080 INFO [com.service.threads.TaskJob] - handling task: user_event_type_utc_version_processing 2, 0, 3, 2007-04-23T13:30:00.000+01:00, 992, true
    2007-04-24 23:05:00,088 INFO [com.service.threads.TaskJob] - failed completing task - last failed acknowledgment: responseCode_usersId ddf62a2ac0ba13845aa938ef8ca5a278, 2
    2007-04-24 23:05:00,096 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  23:05:00 24/Apr/2007 with resulting trigger instruction code: DO NOTHING
    2007-04-24 23:05:00,101 INFO [com.service.threads.TaskJob] - failed completing task - last failed acknowledgment: responseCode_usersId ddf62a2ac0ba13845aa938ef8ca5a278, 2
    2007-04-24 23:05:00,105 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  23:05:00 24/Apr/2007 with resulting trigger instruction code: DO NOTHING
    2007-04-24 23:10:00,012 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  23:10:00 24/Apr/2007
    2007-04-24 23:10:00,070 INFO [com.service.threads.TaskJob] - handling task: user_event_type_utc_version_processing 2, 0, 3, 2007-04-23T13:30:00.000+01:00, 996, true
    2007-04-24 23:10:00,090 INFO [com.service.threads.TaskJob] - failed completing task - last failed acknowledgment: responseCode_usersId ddf62a2ac0ba13845aa938ef8ca5a278, 2
    2007-04-24 23:10:00,099 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  23:10:00 24/Apr/2007 with resulting trigger instruction code: DO NOTHING
    2007-04-24 23:15:00,021 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  23:15:00 24/Apr/2007
    2007-04-24 23:15:00,027 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  23:15:00 24/Apr/2007 with resulting trigger instruction code: DO NOTHING

  5. #15
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Interesting. I would presume it's fired twice because it was told to? Otherwise it would fire twice everytime. Just thinking out loud really.

  6. #16

    Default not quite!

    Having thought that the duplicate log problem had fixed itself, I now notice that whilst my log file doesn't show jobs duplicating in itself, it does duplicate jobs in a different log file (log.1)!

    The files show the same times with different threads executing! (I assume they are different threads because of the @address is different). And my error - which needs fixing fundamentally - is caused by these duplicate jobs.

    Can anyone suggest where to start looking?



    log
    Code:
    2007-05-05 09:50:00,020 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  09:50:00 05/May/2007
    2007-05-05 09:50:00,024 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  09:50:00 05/May/2007 with resulting trigger instruction code: DO NOTHING
    2007-05-05 09:55:00,021 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  09:55:00 05/May/2007
    2007-05-05 09:55:00,023 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  09:55:00 05/May/2007 with resulting trigger instruction code: DO NOTHING
    2007-05-05 10:00:00,014 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  10:00:00 05/May/2007
    2007-05-05 10:00:00,023 INFO [com.service.threads.TaskJob] - task to assess (by thread: com.service.threads.TaskJob@2933dc): user_event_type_utc_version_processing 56, 200, 2, 2007-05-05T10:00:00.000+01:00, 0, false
    2007-05-05 10:00:00,059 INFO [com.service.threads.TaskJob] - handling task (by thread: com.service.threads.TaskJob@2933dc): user_event_type_utc_version_processing 56, 200, 2, 2007-05-05T10:00:00.000+01:00, 2, true
    2007-05-05 10:00:00,112 INFO [com.service.TaskServiceImpl] - sending task email: user_event_reminderUtc_others 56, 200, 2007-05-05T10:00:00.000+01:00,  : x@x.com
    2007-05-05 10:00:00,112 INFO [com.service.TaskServiceImpl] - attempting to parse: SimpleMailMessage: from=reminder@co.uk; replyTo=x@x.com; to=x@x.com; cc=; bcc=; sentDate=null; subject=Birthday: Adrian: 12 May 2007; text=Birthday: Adrian: 12 May 2007
    2007-05-05 10:00:00,237 INFO [com.service.TaskServiceImpl] - sent: SimpleMailMessage: from=reminder@co.uk; replyTo=x@x.com; to=x@x.com; cc=; bcc=; sentDate=null; subject=Birthday: Adrian: 12 May 2007; text=Birthday: Adrian: 12 May 2007
    2007-05-05 10:00:00,249 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 1062, SQLState: 23000
    2007-05-05 10:00:00,249 ERROR [org.hibernate.util.JDBCExceptionReporter] - Duplicate entry '56-200-2007-05-05 10:00:00' for key 1
    2007-05-05 10:00:00,249 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] - Could not synchronize database state with session
    org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
    log.1
    Code:
    2007-05-05 09:50:00,021 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  09:50:00 05/May/2007
    2007-05-05 09:50:00,026 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  09:50:00 05/May/2007 with resulting trigger instruction code: DO NOTHING
    2007-05-05 09:55:00,013 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  09:55:00 05/May/2007
    2007-05-05 09:55:00,016 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  09:55:00 05/May/2007 with resulting trigger instruction code: DO NOTHING
    2007-05-05 10:00:00,016 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger fired job DEFAULT.jobDetail at:  10:00:00 05/May/2007
    2007-05-05 10:00:00,024 INFO [com.service.threads.TaskJob] - task to assess (by thread: com.service.threads.TaskJob@10bd379): user_event_type_utc_version_processing 56, 200, 2, 2007-05-05T10:00:00.000+01:00, 0, false
    2007-05-05 10:00:00,075 INFO [com.service.threads.TaskJob] - handling task (by thread: com.service.threads.TaskJob@10bd379): user_event_type_utc_version_processing 56, 200, 2, 2007-05-05T10:00:00.000+01:00, 2, true
    2007-05-05 10:00:00,115 INFO [com.service.TaskServiceImpl] - sending task email: user_event_reminderUtc_others 56, 200, 2007-05-05T10:00:00.000+01:00,  : x@x.com
    2007-05-05 10:00:00,115 INFO [com.service.TaskServiceImpl] - attempting to parse: SimpleMailMessage: from=reminder@co.uk; replyTo=x@x.com; to=x@x.com; cc=; bcc=; sentDate=null; subject=Birthday: Adrian: 12 May 2007; text=Birthday: Adrian: 12 May 2007
    2007-05-05 10:00:00,214 INFO [com.service.TaskServiceImpl] - sent: SimpleMailMessage: from=reminder@co.uk; replyTo=x@x.com; to=x@x.com; cc=; bcc=; sentDate=null; subject=Birthday: Adrian: 12 May 2007; text=Birthday: Adrian: 12 May 2007
    2007-05-05 10:00:00,221 INFO [com.service.threads.TaskJob] - resetting task: user_event_type_utc_version_processing 56, 200, 2, 2007-05-05T10:00:00.000+01:00, 2, true
    2007-05-05 10:00:00,239 INFO [com.service.threads.TaskJob] - reset task to (if same details, will be dropped): user_event_type_utc_version_processing 56, 200, 2, 2008-05-05T09:00:00.000Z, 3, false
    2007-05-05 10:00:00,239 INFO [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] - Trigger DEFAULT.cronTrigger completed firing job DEFAULT.jobDetail at  10:00:00 05/May/2007 with resulting trigger instruction code: DO NOTHING

    here's my log properties file
    Code:
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.file.File=log
    log4j.appender.file.MaxFileSize=512KB
    log4j.appender.file.MaxBackupIndex=5
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%d %p [%c] - %m%n
    
    log4j.rootLogger=WARN, file
    
    # duplicate jobs
    log4j.category.org.quartz=INFO
    log4j.category.com.service.threads.TaskJob=INFO
    log4j.category.com.service.threads.ExpiryJob=INFO
    log4j.category.com.service.threads.SendMessageThread=INFO
    log4j.category.com.service.TaskServiceImpl=INFO
    log4j.category.com.service.mobile.MobileProviderServiceClickATell=INFO
    threading context
    Code:
    	<!-- THREADS -->
    
    	<bean id="sendMessageThread" class="com.service.threads.SendMessageThread">
    		<property name="taskExecutor"><ref bean="taskExecutor"/></property>
    		<property name="taskService"><ref bean="taskServiceTarget"/></property>
    		<property name="sendMessageService"><ref bean="sendMessageService"/></property>
    	</bean>
    	<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    		<property name="corePoolSize" value="5"/>
    		<property name="maxPoolSize" value="10"/>
    	</bean>

  7. #17
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I'm scratching my head for ideas. It would be useful to see what happens when you start the server, do you see the context starting twice? Just to double check, there aren't any contexts created anywhere in the application.
    Last edited by karldmoore; May 7th, 2007 at 04:44 AM.

  8. #18
    Join Date
    Nov 2006
    Location
    Bangalore
    Posts
    24

    Default

    Hi,

    Actually I faced the same Problem but it has been solved (Not by me) but how i dont know the code look like this.........may be it will help........


    <!-- Swap Job 2 Starts -->
    <bean id="numberSwapJob2" class="org.springframework.scheduling.quartz.JobDe tailBean">
    <property name="jobClass">
    <value>com.sunrocket.actions.SwapJob2</value>
    </property>
    <property name="jobDataAsMap">
    <map>
    <entry key="isProduction">
    <value>0</value>
    </entry>
    </map>
    </property>
    </bean>

    <bean id="numberSwapJob2Trigger" class="org.springframework.scheduling.quartz.CronT riggerBean">
    <property name="jobDetail">
    <ref bean="numberSwapJob2"/>
    </property>
    <property name="cronExpression">
    <value>0 0/2 * * * ?</value>
    </property>
    </bean>

    <bean id="numberSwapJob2scheduler" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="triggers">
    <list>
    <ref bean="numberSwapJob2Trigger"/>
    </list>
    </property>
    <property name="configLocation">
    <value>classpath:quartz.properties</value>
    </property>
    </bean>


    May be it may help You

  9. #19
    Join Date
    Sep 2009
    Posts
    2

    Default

    Thanks Saranga. I tried with your approach. No luck for me!
    Have anyone found the reason and solution for this? I'm totally flummoxed by this issue.
    Here is the XML and com.autoquake.service.SaiJob::run is getting invoked twice everytime! How do I check if there are 2 application contexts and thus 2 independent instances of this bean.
    Code:
    <bean id="saischedular"
    		class="com.autoquake.service.SaiJob">
    	</bean>
    
    	<bean id="saijob"
    		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    		<property name="targetObject"
    			ref="saischedular" />
    			
    		<property name="targetMethod" value="run" />
    		<property name="concurrent" value="false"></property>
    	</bean>
    
    	<bean id="saiJobTrigger"
    		class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail"
    			ref="saijob" />
    				<property name="cronExpression" value="0 * * * * ?" />
    	</bean>
    Last edited by saiprasad; Sep 30th, 2009 at 03:03 AM.

  10. #20
    Join Date
    Oct 2009
    Posts
    1

    Default

    Hi all,

    I was struggling with Spring starting Quartz multiple times as well, and I finally figured it out.

    In my web.xml, I was defining both my ContextLoaderListener and my DispatcherServlet, just like always...

    Code:
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring-servlet.xml</param-value>
        </context-param>
    
    ...
    
        <servlet>
            <servlet-name>spring</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/spring-servlet.xml</param-value>
            </init-param>
        </servlet>
    And this is where I realized I was making my mistake... The ContextLoaderListener and the dispatcherServlet both define a context, and because they were pointing to the same config file, the Quartz schedule (and everything else actually) was being started twice. Basically, from what I understand, the ContextLoaderListener can be used to define beans that are used throughout tomcat, including other application running in the instance. The DispatcherServlet defined the context and beans that were specific to the Web Application.

    I separated the web application specific beans from the more general spring beans, and voilą, no more duplicate processes!

    I hope that helps others who are having similar problems.

Posting Permissions

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