I am trying to create a base Spring project with Maven on Eclipse Kepler (with m2eclipse installed). No errors are reported by Eclipse but when I hit Run on Server (or run Maven Install) only the original files from META-INF and WEB-INF files are deployed. This does not include my dispatcher-servlet.xml config file thus causing a FileNotFoundException
:
java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
How can I fix this?
This is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dispatcher-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
And this is a screencap of my project's folder:
As you can see only selected files are shown in Deployed resources.
Since it is a maven project .
you might have converted maven project to dynamic web project I guess.
Follow the steps
Go to project properties (right click at last click peoperties)
click/select Deployment assembly at the left side
the root(/) deploy path may be pointing to src/main/webapp , select this and click remove button
click on add button , select a directive type folder, select your WebContent folder
Now try to clean and run your application on server.
Solution 2
and restart your server.
Note that the maven dynamic web project it always look in to src/main/webapp by default.
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With