Java – quartz triggers the bean cache problem twice?
Spring report XML will
<bean id="scheduleReportEmailJob" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="schedule.ReportQuartzJobBean"/> <property name="jobDataAsMap"> <map> <entry key="reportService" value-ref="reportService"/> </map> </property> </bean> <bean id="cronEmailTrigger" class="org.springframework.scheduling.quartz.crontriggerBean"> <property name="jobDetail" ref="scheduleReportEmailJob"/> <property name="cronExpression" value="0 0,15,30,45 * ? * MON-FRI"/> </bean> <bean id="scheduler" class="org.springframework.scheduling.quartz.Schedulerfactorybean"> <property name="triggers"> <list> <ref bean="cronEmailTrigger"/> </list> </property> <property name="quartzProperties"> <props> <prop key="org.quartz.scheduler.instanceName">Reports</prop> <prop key="org.quartz.scheduler.instanceId">FirstInstance</prop> <prop key="org.quartz.scheduler.rmi.export">false</prop> <prop key="org.quartz.scheduler.rmi.proxy">false</prop> <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop> <prop key="org.quartz.threadPool.threadCount">1</prop> <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop> <prop key="org.quartz.scheduler.jobFactory.class">org.quartz.simpl.SimpleJobFactory</prop> </props> </property> </bean>
private static beanfactory factory = new ClassPathXmlApplicationContext("spring-report.xml");
When I start Tomcat
2011-02-07 06:46:57,005(ISO8601) [main] DEBUG org.springframework.beans.factory.support.DefaultListablebeanfactory - Invoking afterPropertiesSet() on bean with name 'scheduler' 2011-02-07 06:46:57,083(ISO8601) [main] INFO org.quartz.core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class org.quartz.core.Schedu lerSignalerImpl 2011-02-07 06:46:57,083(ISO8601) [main] INFO org.quartz.core.QuartzScheduler - Quartz Scheduler v.1.6.3 created. 2011-02-07 06:46:57,084(ISO8601) [main] INFO org.quartz.core.QuartzScheduler - JobFactory set to: org.quartz.simpl.SimpleJobFactory@3dd510be 2011-02-07 06:46:57,085(ISO8601) [main] INFO org.quartz.simpl.RAMJobStore - RAMJobStore initialized. 2011-02-07 06:46:57,085(ISO8601) [main] INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler 'Reports' initialized from an externally provided prop erties instance. 2011-02-07 06:46:57,085(ISO8601) [main] INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler version: 1.6.3 2011-02-07 06:46:57,087(ISO8601) [main] INFO org.quartz.core.QuartzScheduler - JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactor y@206fa7ec 2011-02-07 06:46:57,094(ISO8601) [main] INFO org.springframework.scheduling.quartz.Schedulerfactorybean - Starting Quartz Scheduler Now 2011-02-07 06:46:57,094(ISO8601) [main] INFO org.quartz.core.QuartzScheduler - Scheduler Reports_$_FirstInstance started. 2011-02-07 06:46:57,139(ISO8601) [main] DEBUG org.springframework.beans.factory.support.DefaultListablebeanfactory - Finished creating instance of bean 'sc heduler' 2011-02-07 06:46:57,140(ISO8601) [main] DEBUG org.springframework.context.support.ClassPathXmlApplicationContext - Publishing event in context [org.springf ramework.context.support.ClassPathXmlApplicationContext@4275b35]: org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.s upport.ClassPathXmlApplicationContext@4275b35: display name [org.springframework.context.support.ClassPathXmlApplicationContext@4275b35]; startup date [Mon Fe b 07 06:46:55 EST 2011]; root of context hierarchy]
After a period of time after I start tomcat, jobs will be activated twice. If I delete all caches from the working directory and the exploded war file and redeploy it, the job will only be activated once Any ideas? Maybe some beans?
@Jhouse redeployment seems to be a problem that I pasted thread dump after redeployment. What is my choice?
@jhouse
Object. "Reports_quartzschedulerthread" prio = 10 TID = 0x00002aab0c10b000 NID = 0x1dc0 [0x0000000044501000] Java in wait() lang.Thread. State:TIMED_ Waiting (on object monitor) at Java lang.Object. Wait (native method) – wait for < 0x00002aac9e6d298 > (a Java. Lang. object) at org quartz. core. QuartzSchedulerThread. Run (quartzschedulerthread. Java: 433) – locked < 0x00002aac9e6d298 > (a Java. Lang. object)
Object. "Reports_worker-1" prio = 10 TID = 0x00002aab0c10a800 NID = 0x1dbf [0x0000000044400000] Java in wait() lang.Thread. State:TIMED_ Waiting (on object monitor) at Java lang.Object. Wait (native method) – wait < 0x00002aac9e4c980 > (a org. Quartz. SimpleThreadPool $workerthread) at org quartz. simpl. SimpleThreadPool $WorkerThread. Run (SimpleThreadPool. Java: 519) – locked < 0x00002aac9e4c980 > (a org. Quartz. Simpl. SimpleThreadPool $workerthread)
Object. "Reports_quartzschedulerthread" prio = 10 TID = 0x00002aab0841b800 NID = 0x1da3 [0x0000000041715000] Java in wait() lang.Thread. State:TIMED_ Waiting (on object monitor) at Java lang.Object. Wait (native method) – wait for < 0x00002aac4fc71d0 > (a Java. Lang. object) at org quartz. core. QuartzSchedulerThread. Run (quartzschedulerthread. Java: 433) – locked < 0x00002aac4fc71d0 > (a Java. Lang. object)
Object. "Reports_worker-1" prio = 10 TID = 0x00002aab091a3000 NID = 0x1da2 [0x0000000041614000] Java in wait() lang.Thread. State:TIMED_ Waiting (on object monitor) at Java lang.Object. Wait (native method) – wait < 0x00002aac4e21b10 > (a org. Quartz. SimpleThreadPool $workerthread) at org quartz. simpl. SimpleThreadPool $WorkerThread. Run (SimpleThreadPool. Java: 519) – locked < 0x00002aac4e21b10 > (a org. Quartz. Simpl. SimpleThreadPool $workerthread)
If I stop the server, then check that the thread dump is empty, and then start (do not clean up) the server, the thread pump has duplicate threads running
Solution
I wonder if you are also on the web Spring report. XML is configured xml? like this?
<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring-report.xml </param-value> </context-param>
The reason I ask is because you made the above statement: –
private static beanfactory factory = new ClassPathXmlApplicationContext("spring-report.xml");
If you're on the web Both XML and Java code have spring report XML, then yes, it may activate the job twice