8

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>
Gregory Mazur
  • 2,429
  • 4
  • 16
  • 26

6 Answers6

5

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

Gregory Mazur
  • 2,429
  • 4
  • 16
  • 26
  • I just recently had this issue. I solved it by updating the java.version in the pom and then recompiling. Then the error went away. – dev4life Jan 14 '22 at 19:40
2

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.

LINSOFT
  • 21
  • 2
1

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>
M Sach
  • 33,416
  • 76
  • 221
  • 314
1

I was having this same problem. It turned out that I was using an old companies settings.xml file for Maven user settings file. If someone is having this problem try using the Maven template users file.

0
  1. Add spring mvc.jar file (if you are using spring and mvc) to the class libraries
  2. Make sure that [name]-sevlet.xml file is set properly. use name inside the "sevlet-name" name "servlet-name" in the web.xml.
Bidou
  • 7,378
  • 9
  • 47
  • 70
javaguru
  • 1
  • 1
-1

I add the path for Web module. Using Intellij click project structure and then select Facets. Deployment Descriptors probably must be empty(its not good), so add the path.

ArcherSSS
  • 1
  • 3