I launched the Spring Framework / SmartGWT web application, now the Quartz task added. The work should be performed every day at 2 am and selects the winners from the database table. From my logs, I see that it runs twice, at the same time it seems, because, as you can see, the logs overlap:
Generating winners of yesterday... Generating winners of yesterday... winning id's: 15 done, mail queue is filled. winning id's: 18 done, mail queue is filled.
My applicationContext.xml is as follows:
<beans:bean id="GenerateWinnersAndFillMailingQueueJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <beans:property name="targetObject" ref="GenerateWinnersAndFillMailingQueueJobExecutor"/> <beans:property name="targetMethod" value="execute"/> </beans:bean> <beans:bean id="GenerateWinnersAndFillMailingQueueJob" class="org.springframework.scheduling.quartz.CronTriggerBean"> <beans:property name="jobDetail" ref="GenerateWinnersAndFillMailingQueueJobDetail"/> <beans:property name="cronExpression" value="0 0 2 * * ?"/> </beans:bean> ... another quartz jobs is defined here, omitted for clarity ... <beans:bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <beans:property name="triggers"> <beans:list> <beans:ref bean="GenerateWinnersAndFillMailingQueueJob"/> <beans:ref bean="SendEmailsFromMailQueueJob"/> </beans:list> </beans:property> </beans:bean>
I do not quite understand what is wrong here, this is a fairly simple use case. When I test this locally, on the server that comes with the GWT development mode, it works. Only when deploying to Tomcat6 on Ubuntu 10.04 LTS do I get this problem.
Any ideas?
** edit: after the hint from the comments, increasing the log level, it seems that Spring works twice. A restart of the tomcat server indicates that two sources are generated, approximately 4 seconds apart.
2011-08-29 08:49:22,567 {ABSOLUTE} INFO XmlWebApplicationContext,Thread-9:1002 - Closing Root WebApplicationContext: startup date [Sun Aug 28 20:53:39 CEST 2011]; root of context hierarchy 2011-08-29 08:49:22,569 {ABSOLUTE} INFO DefaultLifecycleProcessor,Thread-9:345 - Stopping beans in phase 2147483647 2011-08-29 08:49:22,589 {ABSOLUTE} INFO QuartzScheduler,Thread-9:537 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean merchantDao, AdvertisementSimpleJsonWebservice, advertisementDao, ContactFormSubmitsSimpleJsonWebservice, contactFormSubmitsDao, PlayerCustomJsonWebservice, PlayerCustomJsonWebserviceImpl, submitSolutionDao, GenerateWinnersAndFillMailingQueueJobExecutor, GenerateWinnersAndFillMailingQueueJobDetail, GenerateWinnersAndFillMailingQueueJob 2011-08-29 08:49:22,567 {ABSOLUTE} INFO XmlWebApplicationContext,Thread-9:1002 - Closing Root WebApplicationContext: startup date [Sun Aug 28 20:53:39 CEST 2011]; root of context hierarchy 2011-08-29 08:49:22,569 {ABSOLUTE} INFO DefaultLifecycleProcessor,Thread-9:345 - Stopping beans in phase 2147483647 2011-08-29 08:49:22,589 {ABSOLUTE} INFO QuartzScheduler,Thread-9:537 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean merchantDao, AdvertisementSimpleJsonWebservice, advertisementDao, ContactFormSubmitsSimpleJsonWebservice, contactFormSubmitsDao, PlayerCustomJsonWebservice, PlayerCustomJsonWebserviceImpl, submitSolutionDao, GenerateWinnersAndFillMailingQueueJobExecutor, GenerateWinnersAndFillMailingQueueJobDetail, GenerateWinnersAndFillMailingQueueJob 2011-08-29 08:49:22,567 {ABSOLUTE} INFO XmlWebApplicationContext,Thread-9:1002 - Closing Root WebApplicationContext: startup date [Sun Aug 28 20:53:39 CEST 2011]; root of context hierarchy 2011-08-29 08:49:22,569 {ABSOLUTE} INFO DefaultLifecycleProcessor,Thread-9:345 - Stopping beans in phase 2147483647 2011-08-29 08:49:22,589 {ABSOLUTE} INFO QuartzScheduler,Thread-9:537 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean
Two Spring instances later start:
2011-08-29 08:49:26,484 {ABSOLUTE} INFO ContextLoader,main:187 - Root WebApplicationContext: initialization started ... 2011-08-29 08:49:31,221 {ABSOLUTE} INFO ContextLoader,main:187 - Root WebApplicationContext: initialization started
What could be the reason for this and what to do?