Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse not deploying my web app properly

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:

enter image description here

As you can see only selected files are shown in Deployed resources.

like image 470
Gabriel Sanmartin Avatar asked Aug 14 '13 08:08

Gabriel Sanmartin


1 Answers

Since it is a maven project .

you might have converted maven project to dynamic web project I guess.

Follow the steps

  1. Go to project properties (right click at last click peoperties)

  2. click/select Deployment assembly at the left side

  3. the root(/) deploy path may be pointing to src/main/webapp , select this and click remove button

  4. 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

  1. Actually you need to copy/put all your WebContent files and folder to src/main/webapp

and restart your server.

Note that the maven dynamic web project it always look in to src/main/webapp by default.

Hope it helps

like image 175
Suryaprakash Pisay Avatar answered Nov 08 '22 04:11

Suryaprakash Pisay