Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servlet cannot be resolved in web.xml

For some reason idea lights dispatcher servlet and when I launch tomcat get the 404 error. I`m using spring mvc and Maven, here is the picture of web.xml web.xml Appreciate every answer=) webapp/web.xml

<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_3_0.xsd"
         version="3.0">
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>
like image 851
Gregory Mazur Avatar asked Aug 23 '15 11:08

Gregory Mazur


3 Answers

Found the problem, was using the tomcat7-maven-plugin with compile version of maven-compiler-plugin 1.8, after changing it to 1.7 the problem gone. However is there any similar solutions to tomcat7-maven-plugin?, cause I didnt find tomcat8-maven-plugin in internet

Thanks everyone for participation

like image 102
Gregory Mazur Avatar answered Oct 20 '22 20:10

Gregory Mazur


Open settings below:
Project settings -> Facets -> Web -> Deployment Descriptors

check the path here and ensure it's available. If not, click the green + to add your web module path.

like image 21
LINSOFT Avatar answered Oct 20 '22 22:10

LINSOFT


You need to add servlet mapping also and then add spring-webmvc-version.jar in classpath

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
like image 1
M Sach Avatar answered Oct 20 '22 21:10

M Sach