-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
Christian Ihle opened SPR-6656 and commented
ScheduledAnnotationBeanPostProcessor.onApplicationEvent is first run when the Root WebApplicationContext initializes. Then run again when the FrameworkServlet initializes. Each time onApplicationEvent runs a new schedule is registered.
I have modified the task-basic sample from https://src.springframework.org/svn/spring-samples/task-basic/trunk/ to run as a web application for verification. Will attach the source and war file.
This is the console output of task-basic in jetty. It's the same in tomcat. Notice the "processing next 10..." text that shows up twice every 30 seconds. When the application runs from a main class outside a web server the "processing next 10..." text only shows up once every 30 seconds.
2010-01-08 10:38:22.612::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2010-01-08 10:38:22.738::INFO: jetty-6.1.17
2010-01-08 10:38:23.212:/task-basic:INFO: Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri Jan 08 10:38:23 CET 2010]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [org/springframework/samples/task/basic/annotation/config.xml]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@144b9ff: defining beans [scheduledProcessor,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.scheduling.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.internalScheduledAnnotationProcessor]; root of factory hierarchy
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 13801 ms
processing next 10 at Fri Jan 08 10:38:37 CET 2010
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'SpringServlet': initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'SpringServlet-servlet': startup date [Fri Jan 08 10:38:37 CET 2010]; parent: Root WebApplicationContext
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/servlet-context.xml]
2010-01-08 10:38:37.139:/task-basic:INFO: Initializing Spring FrameworkServlet 'SpringServlet'
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@fffa61: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@144b9ff
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'SpringServlet': initialization completed in 4407 ms
processing next 10 at Fri Jan 08 10:38:41 CET 2010
2010-01-08 10:38:41.557::INFO: Opened C:\Users\Christian\Programmer\jetty-6.1.17\logs\2010_01_08.request.log
2010-01-08 10:38:41.641::INFO: Started SelectChannelConnector@0.0.0.0:8080
processing next 10 at Fri Jan 08 10:39:07 CET 2010
processing next 10 at Fri Jan 08 10:39:11 CET 2010
processing next 10 at Fri Jan 08 10:39:37 CET 2010
processing next 10 at Fri Jan 08 10:39:41 CET 2010
Affects: 3.0 GA
Reference URL: http://forum.springsource.org/showthread.php?t=80225
Attachments:
- org.springframework.samples.task.basic-1.0.0-SNAPSHOT.war (3.11 MB)
- task-basic.zip (11.41 kB)
Issue Links:
- @Scheduled tasks scheduled multiple times when a child application context is refreshed [SPR-6663] #11329
@Scheduled
tasks scheduled multiple times when a child application context is refreshed ("is duplicated by") - Scheduled tasks seem to run twice [SPR-6859] #11525 Scheduled tasks seem to run twice ("is duplicated by")
- JmsListener/ScheduledAnnotationBeanPostProcessor should use SmartInitializingSingleton instead of ContextRefreshedEvent [SPR-12039] #16655 JmsListener/ScheduledAnnotationBeanPostProcessor should use SmartInitializingSingleton instead of ContextRefreshedEvent
Referenced from: commits 4ca54fb