[SPRING] tomcat 6 / Ubuntu 10.04LTS에 배포 할 때 Quartz 작업이 두 번 실행됩니다.
SPRINGtomcat 6 / Ubuntu 10.04LTS에 배포 할 때 Quartz 작업이 두 번 실행됩니다.
저는 Spring Framework / SmartGWT 기반의 웹 애플리케이션을 실행 시켰습니다. 이제 Quartz 작업이 추가되었습니다. 작업은 매일 오전 2시에 실행되고 DB 테이블에서 수상자를 선택합니다. 내 로그에서 볼 때 볼 수 있듯이 로그가 중복되므로 동시에 두 번 실행됩니다.
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.
내 applicationContext.xml은 다음과 같습니다.
<!-- initiates and calls the job -->
<beans:bean id="GenerateWinnersAndFillMailingQueueJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<beans:property name="targetObject" ref="GenerateWinnersAndFillMailingQueueJobExecutor"/>
<beans:property name="targetMethod" value="execute"/>
</beans:bean>
<!-- here's where we use the Cron like scheduling expression to define when the bean is run. -->
<beans:bean id="GenerateWinnersAndFillMailingQueueJob" class="org.springframework.scheduling.quartz.CronTriggerBean">
<beans:property name="jobDetail" ref="GenerateWinnersAndFillMailingQueueJobDetail"/>
<!-- run every morning at 2AM -->
<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>
여기에 무엇이 잘못되었는지는 실제로 알 수 없으며 매우 간단한 사용 사례입니다. GWT 개발 모드와 함께 제공되는 서버에서 로컬로 테스트 할 때 작동합니다. Ubuntu 10.04 LTS에서 Tomcat6에 배포 할 때만이 문제가 발생합니다.
어떤 아이디어?
** 편집 : 코멘트에서 힌트를 얻은 후 로그 수준을 높이면 Spring이 두 번 실행되는 것 같습니다. Tomcat 서버를 다시 시작하면 약 4 초 간격으로 두 개의 스프링이 인스턴스화됩니다.
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#0_$_NON_CLUSTERED paused.
2011-08-29 08:49:22,592 {ABSOLUTE} INFO DefaultListableBeanFactory,Thread-9:422 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12e14ebc: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,MerchantSimpleJsonWebservice,merchantDao,AdvertisementSimpleJsonWebservice,advertisementDao,ContactFormSubmitsSimpleJsonWebservice,contactFormSubmitsDao,PlayerCustomJsonWebservice,PlayerCustomJsonWebserviceImpl,submitSolutionDao,GenerateWinnersAndFillMailingQueueJobExecutor,GenerateWinnersAndFillMailingQueueJobDetail,GenerateWinnersAndFillMailingQueueJob,SendEmailsFromMailQueueJobExecutor,SendEmailsFromMailQueueJobDetail,SendEmailsFromMailQueueJob,org.springframework.scheduling.quartz.SchedulerFactoryBean#0,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.authentication.AnonymousAuthenticationProvider#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.config.http.UserDetailsServiceInjectionBeanPostProcessor#0,org.springframework.security.filterChainProxy,sessionAuthenticationStrategy,sessionRegistry,propertyConfigurer,org.springframework.security.authentication.dao.DaoAuthenticationProvider#0,org.springframework.security.authentication.DefaultAuthenticationEventPublisher#0,org.springframework.security.authenticationManager,saltSource,dataSource,jdbcTemplate,passwordEncoder,jdbcUserService,loggerListener,formLoginFilter,authenticationEntryPoint,accessDeniedHandler,concurrencyFilter]; root of factory hierarchy
2011-08-29 08:49:22,601 {ABSOLUTE} INFO SchedulerFactoryBean,Thread-9:760 - Shutting down Quartz Scheduler
2011-08-29 08:49:22,601 {ABSOLUTE} INFO QuartzScheduler,Thread-9:616 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED shutting down.
2011-08-29 08:49:22,602 {ABSOLUTE} INFO QuartzScheduler,Thread-9:537 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED paused.
2011-08-29 08:49:22,603 {ABSOLUTE} INFO QuartzScheduler,Thread-9:688 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED shutdown complete.
2011-08-29 08:49:22,882 {ABSOLUTE} INFO XmlWebApplicationContext,Thread-9:1002 - Closing Root WebApplicationContext: startup date [Sun Aug 28 20:53:34 CEST 2011]; root of context hierarchy
2011-08-29 08:49:22,883 {ABSOLUTE} INFO DefaultLifecycleProcessor,Thread-9:345 - Stopping beans in phase 2147483647
2011-08-29 08:49:22,903 {ABSOLUTE} INFO QuartzScheduler,Thread-9:537 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED paused.
2011-08-29 08:49:22,904 {ABSOLUTE} INFO DefaultListableBeanFactory,Thread-9:422 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@402fb002: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,MerchantSimpleJsonWebservice,merchantDao,AdvertisementSimpleJsonWebservice,advertisementDao,ContactFormSubmitsSimpleJsonWebservice,contactFormSubmitsDao,PlayerCustomJsonWebservice,PlayerCustomJsonWebserviceImpl,submitSolutionDao,GenerateWinnersAndFillMailingQueueJobExecutor,GenerateWinnersAndFillMailingQueueJobDetail,GenerateWinnersAndFillMailingQueueJob,SendEmailsFromMailQueueJobExecutor,SendEmailsFromMailQueueJobDetail,SendEmailsFromMailQueueJob,org.springframework.scheduling.quartz.SchedulerFactoryBean#0,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.authentication.AnonymousAuthenticationProvider#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.config.http.UserDetailsServiceInjectionBeanPostProcessor#0,org.springframework.security.filterChainProxy,sessionAuthenticationStrategy,sessionRegistry,propertyConfigurer,org.springframework.security.authentication.dao.DaoAuthenticationProvider#0,org.springframework.security.authentication.DefaultAuthenticationEventPublisher#0,org.springframework.security.authenticationManager,saltSource,dataSource,jdbcTemplate,passwordEncoder,jdbcUserService,loggerListener,formLoginFilter,authenticationEntryPoint,accessDeniedHandler,concurrencyFilter]; root of factory hierarchy
2011-08-29 08:49:22,913 {ABSOLUTE} INFO SchedulerFactoryBean,Thread-9:760 - Shutting down Quartz Scheduler
2011-08-29 08:49:22,914 {ABSOLUTE} INFO QuartzScheduler,Thread-9:616 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED shutting down.
2011-08-29 08:49:22,914 {ABSOLUTE} INFO QuartzScheduler,Thread-9:537 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED paused.
2011-08-29 08:49:22,915 {ABSOLUTE} INFO QuartzScheduler,Thread-9:688 - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED shutdown complete.
2011-08-29 08:49:26,484 {ABSOLUTE} INFO ContextLoader,main:187 - Root WebApplicationContext: initialization started
나중에 두 개의 Spring 인스턴스가 시작된 것으로 보인다.
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
무엇이 이것을 일으킬 수 있으며, 무엇을해야할까요?
해결법
-
==============================
1.고쳐 봤지만 석영이 두 번 실행되는 것뿐만 아니라 내 앱이 두 번 배포되었습니다. Tomcat 문서에서 다음과 같은 이유 때문입니다.
고쳐 봤지만 석영이 두 번 실행되는 것뿐만 아니라 내 앱이 두 번 배포되었습니다. Tomcat 문서에서 다음과 같은 이유 때문입니다.
나는 mod_jk를 작동시키는 방법에 대한 튜토리얼을 따라 갔다. 그리고이 튜토리얼은 그 결함을 포함했다.
-
==============================
2.저에게는 자동 배포가 문제 였고 비활성화하려면 server.xml의 host 요소에 다음 속성을 지정해야했습니다.
저에게는 자동 배포가 문제 였고 비활성화하려면 server.xml의 host 요소에 다음 속성을 지정해야했습니다.
deployOnStartup="false" autoDeploy="false"
그래서 내 호스트 요소는 다음과 같이 보입니다.
<Host name="localhost" deployOnStartup="false" appBase="webapps" unpackWARs="false" autoDeploy="false">
나는이 문제를 해결하는 데 도움이되는 다른 방법으로이 게시물을 발견했다.
-
==============================
3.결국 Ubunut 시스템에서 하나의 Tomcat 인스턴스 내부에서 여러 응용 프로그램이 실행되고 있습니까? 나는 Quartz가 하나의 자바 VM에서 모든 애플리케이션을 공유 할 수있는 정적 코드를 가지고 있다고 생각한다.
결국 Ubunut 시스템에서 하나의 Tomcat 인스턴스 내부에서 여러 응용 프로그램이 실행되고 있습니까? 나는 Quartz가 하나의 자바 VM에서 모든 애플리케이션을 공유 할 수있는 정적 코드를 가지고 있다고 생각한다.
from https://stackoverflow.com/questions/7223108/quartz-job-runs-twice-when-deployed-on-tomcat-6-ubuntu-10-04lts by cc-by-sa and MIT license