Maven web project HTTP Status [404] – [Not Found]

Chaklader Asfak Arefe

I started amaven-archetype-webapp web project with the following structure using the IntellIJ,

enter image description here

The web.xml file is as following,

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         id="WebApp_ID" version="2.5">

    <display-name>Bitcoin Wallet</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

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

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

The dispatcher-servlet.xml file is provided below,

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">

    <context:component-scan base-package="com.puut.bitcoin.controllers">
    </context:component-scan>

    <mvc:annotation-driven></mvc:annotation-driven>

    <bean id="jspViewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsps/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

    <mvc:resources location="/resources/" mapping="/static/**" />
</beans>

There is no Java source file in the project so far. I get the error HTTP Status [404] – [Not Found].

enter image description here

I clean and build the project with Maven successfully. I upgraded to the OS Sierra and there is no maven installed in the OS. So, I had to manually configured it. Maven related information is here,

$ mvn -version

Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T01:39:06+06:00)
Maven home: /Users/Chaklader/apache-maven-3.5.0
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.4", arch: "x86_64", family: "mac"


$ which mvn 

/Users/Chaklader/apache-maven-3.5.0/bin/mvn

What should I do to run the project?

Update

As mentioned, changed it to

   <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

doesn't help.

xcesco

To use jsp resolver, you have to define a controller like this:

package com.puut.bitcoin.controllers;

@Controller
@RequestMapping(value="/")
public class spaController {

  @RequestMapping(method = RequestMethod.GET)
  public String pagIndex(Model model){

     return "index";
  }
}

In web xml, it's better to explicit declare which configuration file is used by dispatcher servlet.

<!-- Processes application requests -->
<servlet>
    <servlet-name>appServlet</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>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Status: 404-Not found

HTTP Status 404 – Not Found: for controller - no view resolvers found in Idea

HTTP Status 404 - on Eclipse with Tomcat (with no generated web.xml)

HTTP Server Status 404 Error in Spring MVC Project

HTTP Status 404 - Servlet not found

Get HTTP Status 404 - Not Found, when the name of a dynamic web project renamed and deployed on Glassfish with Eclipse

Servlet: HTTP Status 404 - Not Found

How to redirect "HTTP Status 404 – Not Found" to an error information page in tomcat?

HTTP Status [404] ? [Not Found] (The origin server did not find a current representatio)

Response for preflight has invalid http status code 404 in my angular project while consuming web api

HTTP Status 404 Not Found For Jersey REST application with Eclipse and Payara server

HTTP Status 404 – Not Found on Tomcat server

HTTP Status 404 – Not Found tomcat spring

HTTP Status 404 – Not Found Spring Boot

HTTP Status 404 - /com.demo/rest/hello - with Rest project

Why when I run a project created with Maven on Jetty it is not found (404)?

HTTP status 404 error running TimeForm servlet project in NetBeans

JSP/JDBC: HTTP Status 404 - Not Found

Why am I getting HTTP Status 404 - Not Found?

Maven project + java servlets keeps returning 404-not found

Insertion of image in mysql using jsp HTTP Status 404 not found

HTTP Status [404] ? [Not Found] for /login in spring security

Spring Mvc get HTTP Status [404] – [Not Found] after the submission

Spring Mvc App get - HTTP Status [404] – [Not Found]

HTTP Status 404 - Not Found - Servlet and JSP

Eclipse & Tomcat Error: HTTP Status 404 – Not Found:

HTTP 404 status code (Not Found) shown as 302

404 JSP file not found Dynamic Web Module imported project

spring-mvc-404 page not found error in maven project