Question

I'm receiving this error when starting my app :

java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/spring/servlet/servlet-context.xml]

I don't know why Spring is searching for servlet-context.xml . All of my contexts are configured in web-inf/context/portlet Is there a setting I can add to web.xml so tomcat can resolve the contexts from a different dir to /WEB-INF/spring/servlet/servlet-context.xml ? Or is another way of fixing this issue ?

Was it helpful?

Solution

Usually you set the location of the context in your WEB-INF/web.xml file, see here: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#web-integration-common

So your WEB-INF/web.xml file should look something like, check carefully that the contextConfigLocation value points to your context configuration files:

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/context/portlet/*.xml</param-value>
</context-param>

<listener>
 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top