Sep 6th, 2008, 11:18 AM
ContextLoaderListener, SingletonBeanFactoryLocator and DispatcherServlet integration
I have created a J2EE application which contains an EJB module (which has only one MDB) and a Web module.
The web module initializes the spring context through the ContextLoaderListener using some xml files defined in contextConfigLocation. The web module contains also some controllers that use the DispatcherServlet and can access the context that is initialized by the ContextLoaderListener.
I need the MDB to have access to some DAO beans defined in the XMLs initialized by the ContextLoaderListener. According to [blog.springsource.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/]this article I should create a beanRefContext.xml, use ClassPathXmlApplicationContext and put all the XMLs there instead of the contextConfigLocation and then use the SingletonBeanFactoryLocator to get the factory bean and then the DAO beans I need in the MDB (EJB module).
The problem is that when I declare the factory bean (defined in the beanRefContext.xml) in the parentContextKey of the ContextLoaderListener, the DispatcherServlet beans cannot access the rest of the beans defined in the factory bean any more - maybe because another level of hierarchy have been created that It doesn't know how to access.
Do you have any suggestions?
Tags for this Thread