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

  • #16
    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,  : [email protected]
    2007-05-05 10:00:00,112 INFO [com.service.TaskServiceImpl] - attempting to parse: SimpleMailMessage: from=[email protected]; replyTo=[email protected]; to=[email protected]; 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=[email protected]; replyTo=[email protected]; to=[email protected]; 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,  : [email protected]
    2007-05-05 10:00:00,115 INFO [com.service.TaskServiceImpl] - attempting to parse: SimpleMailMessage: from=[email protected]; replyTo=[email protected]; to=[email protected]; 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=[email protected]; replyTo=[email protected]; to=[email protected]; 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>

    Comment


    • #17
      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, 05:44 AM.

      Comment


      • #18
        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

        Comment


        • #19
          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, 04:03 AM.

          Comment


          • #20
            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.

            Comment


            • #21
              Does it really work with WorkManagerTaskExecutor?

              adam_jh, have you tried using org.springframework.scheduling.commonj.WorkManager TaskExecutor as documented in Spring Javadoc at http://static.springsource.org/sprin...kExecutor.html? I'd like to know if the approach suggested there really works. I tried what is suggested for WebSphere 5.1 and couldn't make it work, it still spawned multiple invocations. Thanks,

              Comment


              • #22
                Finally, it's all sorted out!

                After reading through this thread once again, I realized that I was making the same mistake as NodakPaul in the previous posting here. And I have DispatcherPortlet in the mix as well. This made my quartz scheduling setup as well as other beans in the application contexts loading three times!

                Thank you, NodakPaul!

                Comment


                • #23
                  It didn't work after all!

                  See http://forum.springsource.org/showthread.php?t=79690 for details.

                  Comment

                  Working...
                  X