I have a webapp in which I define the base dispatcher-servlet context in web.xml and it loads the applicationContext .
I had a messageSource defined in dispatcher-servlet and it injected it into the controllers in order.
I also have my services defined in applicationContext , and I can embed them in my controllers (defined in the context of dispatcher-servlet ).
But when I moved my definition for messageSource to applicationContext so that some services can allow messages, the dispatcher-servlet context shows that it does not find the messageSource bean and uses the default value, the controllers get the wrong bean.
Any idea why the definition of messageSource in applicationContext will not be displayed in dispatcher-servlet context?
I see that my messageSource bean is loading in the
applicationContext section of the logs:
2058 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'messageSource' 2058 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'messageSource' ... 2082 [main] DEBUG org.springframework.web.context.support.XmlWebApplicationContext - Using MessageSource [mycommons.spring.ResourceBundleMessageSourceWithDefaultResolution: basenames=[messages]]
I see this log in dispatcher-servlet loading:
3858 [main] DEBUG org.springframework.web.context.support.XmlWebApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [ org.springframework.context.support.DelegatingMessageSource@5561 1ed3]
David parks
source share