I have the below defined in the web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:p360UiSpringConfig/p360UiDispatcherServlet-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>p360UiDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Below is how my web-inf looks:
When I start my application in WebLogic I get the below error:
Error java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/p360UiDispatcherServlet-servlet.xml]
Question is when I have defined contextConfigLocation, why is it looking for the spring config file in Web-Inf ?
Edit your contextConfigLocation
in the web.xml
as follows.
EDIT
What is happening is The Spring container is trying to look for a context by <Dispatcher Servlet Name>-servlet.xml
in WEB-INF folder. This is because you haven't specified the <init-param>
for dispatcher servlet p360UiDispatcherServlet
. <context-param>
is used to specify common additional context paths such as DAO, Security etc. This should ideally fix your issue. Please check the modified web.xml
<!-- Any Common Additional Context Paths -->
<!--<context-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</context-param>-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>p360UiDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/p360UiSpringConfig/p360UiDispatcherServlet-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.