Typically, a Spring MVC application has both a ContextLoaderListener and a DispatcherServlet . Both components create their own ApplicationContext , which in turn runs a ContextRefreshedEvent .
DispatcherServlet uses ApplicationContext as created by ContextLoaderListener as a parent. Events fired from child contexts are propagated to the parent context.
Now, if you have an ApplicationListener<ContextRefreshedEvent> defined in the root context (the one loaded by ContextLoaderListener ), it will receive the event twice.
source share