Hi,
I'm working on a Spring + Struts web application. I am using the Delegating Action method, so I have the plug-in defined in struts-config.xml
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in>
Since I need to use the Spring-managed beans in my InitServlet, so I have the following in web.xml.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>Init</servlet-name> <servlet-class>com.na.eshop.web.InitServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
This works but I find that there are two Spring context for my app.
Log
==========================================
- Root WebApplicationContext: initialization started
- Loading Spring root WebApplicationContext
- Loading XML bean definitions from ServletContext resource [WEB-INF/applicationContext.xml]
-
Bean factory for application context [Root WebApplicationContext]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,transactionManager,transactionTemplate,...]; root of BeanFactory hierarchy
- 21 beans defined in application context [Root WebApplicationContext]
........
- Root WebApplicationContext: initialization completed in 531 ms
- Loading validation rules file from '/WEB-INF/validator-rules.xml'
- Loading validation rules file from '/WEB-INF/validation.xml'
- ContextLoaderPlugIn for Struts ActionServlet 'action, module '': initialization started
- Initializing WebApplicationContext for Struts ActionServlet 'action', module ''
- Loading XML bean definitions from ServletContext resource [WEB-INF/applicationContext.xml]
-
Bean factory for application context [WebApplicationContext for namespace 'action-servlet']: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,transactionManager,transactionTemplate,...]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,transactionManager,transactionTemplate,...]; root of BeanFactory hierarchy
- 21 beans defined in application context [WebApplicationContext for namespace 'action-servlet']
.........
==================================================
So my question is is it normal to have 2 contexts for a single web app? If no, how can I reduce to use a single context?
Thanks for your help.
Michael