0

I have defined the contextConfigLocation(s) in web.xml as follows:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/app/servlet-context.xml</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

In the root-context.xml, I have

<context:property-placeholder location="${propFile}" />

Now, I observe that no properties required in the Spring bean configured in the servlet-context.xml or its child context xml (beans:import) can be resolved, though they are clearly defined in the propFile and are resolvable from the root-context.xml or its child context xml.

Also, what is more painful is

if I define mvc:interceptor with mvc:mapping path="/"** inside root-context.xml, the interceptor is not invoked for request pattern ="/rest/*". But the same interceptor is invoked successfully if configured inside servlet-context.xml or its child xml.

Please let me know if I am missing something or is that the expected behavior?

Environment:

Java version: 1.8.0_60, vendor: Oracle Corporation

OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

The version of the most of my Spring dependencies like (spring-context, spring-beans etc.) are resolved by io.spring.platform:platform-bom:Brussels-SR3 to be 4.3.9.RELEASE

lab bhattacharjee
  • 1,617
  • 2
  • 17
  • 33
  • Related : https://stackoverflow.com/questions/25258132/moving-mvc-interceptor-from-module-context-to-web-application-context, https://stackoverflow.com/questions/26306420/spring-interceptors-configured-in-root-applicationcontext-cannot-be-reached-from , https://jira.spring.io/browse/SPR-8994 , http://forum.spring.io/forum/spring-projects/container/4450-propertyplaceholderconfigurer-visibility-in-par-child-ctxs, – lab bhattacharjee Sep 24 '17 at 18:37
  • https://stackoverflow.com/questions/3816617/contextproperty-placeholder-properties-not-accessible-to-the-child-web-cont , https://stackoverflow.com/questions/25610490/difference-between-root-and-web-applicationcontext-spring-mvc – lab bhattacharjee Sep 24 '17 at 18:38

0 Answers0