title: How to troubleshoot HTTP 404 The origin server did not find a current representation for the target resource
body: <p>Following a software demo on Skillsoft, I built a simple Spring MVC Demo app in Eclipse.  The app loads fine and I can hit the home page ("Hello World").  But when I try to hit my controller, I get the following error message</p>
  
  <p><strong>HTTP Status 404 - Not Found</strong></p>
  
  <p><strong>Type</strong> Status Report</p>
  
  <p><strong>Message</strong> /springMVCDemo/WEB-INF/jsp/quote.jsp</p>
  
  <p><strong>Description</strong> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p>
  
  <p>I've studied the following links that describe the same error, but I could not make my code work:</p>
  
  <p><a href="https://stackoverflow.com/questions/43186315/tomcat-404-error-the-origin-server-did-not-find-a-current-representation-for-th">Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists</a></p>
  
  <p><a href="https://stackoverflow.com/questions/11731377/servlet-returns-http-status-404-the-requested-resource-servlet-is-not-availa">Servlet returns &quot;HTTP Status 404 The requested resource (/servlet) is not available&quot;</a></p>
  
  <p><a href="https://stackoverflow.com/questions/43590008/the-origin-server-did-not-find-a-current-representation-for-the-target-resource">The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat</a></p>
  
  <p><a href="https://stackoverflow.com/questions/43931383/the-origin-server-did-not-find-a-current-representation-for-the-target-resource?rq=1">The origin server did not find a current representation for the target resource or is not willing to disclose that one exists</a></p>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;web-app&gt;
      &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt; 
      &lt;servlet&gt;
      &lt;servlet-name&gt;MyDemoApp&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/myDemoApp-servletConfig.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MyDemoApp&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>myDemoApp-servletConfig.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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-4.0.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-4.0.xsd"&gt;
  
  &lt;mvc:annotation-driven/&gt;
  &lt;context:component-scan base-package="com.demo.controllers"&lt;/context:component-scan&gt;
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt;
      &lt;property name="suffix" value=".jsp"/&gt;
  &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>MyDemoController.java</strong></p>
  
  <pre><code>package com.demo.controllers;
  
  import java.util.Random;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  
  @Controller
  public class MyDemoController {
  private String[] quotes = {"To be or not to be -Shakespeare",
                              "Stay hungry you're alone -Dee Snider",
                              "Might as well jump! -David Lee Roth"};
  
  //http://localhost:8080/springMVCDemo/getQuote.html
  @RequestMapping(value="/getQuote")
  public String getRandomQuote(Model model) {
      int rand = new Random().nextInt(quotes.length);
      String randomQuote = quotes[rand];
  
      model.addAttribute("randomQuote", randomQuote);
      return "quote";
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Quote.jsp</strong></p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="ISO-8859-1"&gt;
  &lt;title&gt;My Demo App&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;The quote is:&lt;/h1&gt;
  &lt;p&gt;${randomQuote}&lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p><strong>index.jsp</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;h2&gt;Hello World!&lt;/h2&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Directory Structure</strong></p>
  
  <pre><code>springMVCDemo
  |
  --&gt;main
     --&gt;java
        --&gt;com
           --&gt;demo
              --&gt;controllers
                 --&gt;MyDemoController.java
  --&gt;webapp
     --&gt;WEB-INF
        myDemoApp-servletConfig.xml
        web.xml
        index.jsp
        --&gt;jsp
           --&gt;Quote.jsp
  </code></pre>
  
  <p><strong>What I've tried and the results</strong></p>
  
  <p>Experiment #1:</p>
  
  <pre><code>http://localhost:8080/springMVCDemo
  </code></pre>
  
  <p>Result: Browser displays "Hello World!" as expected</p>
  
  <p>Experiment #2:</p>
  
  <pre><code>http://localhost:8080/springMVCDemo/getQuote.html
  </code></pre>
  
  <p>Expected behaviour: One of three quotes gets displayed</p>
  
  <p>Actual result: HTTP 404 + Eclipse console messages:</p>
  
  <pre><code>Dec 29, 2018 5:59:40 PM org.apache.catalina.core.ApplicationContext log
  INFO: Initializing Spring FrameworkServlet 'MyDemoApp'
  Dec 29, 2018 5:59:40 PM org.springframework.web.servlet.DispatcherServlet initServletBean
  INFO: FrameworkServlet 'MyDemoApp': initialization started
  Dec 29, 2018 5:59:40 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
  INFO: Refreshing WebApplicationContext for namespace 'MyDemoApp-servlet': startup date [Sat Dec 29 17:59:40 EST 2018]; root of context hierarchy
  Dec 29, 2018 5:59:40 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
  INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/myDemoApp-servletConfig.xml]
  Dec 29, 2018 5:59:42 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
  INFO: Mapped "{[/getQuote],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.demo.controllers.MyDemoController.getRandomQuote(org.springframework.ui.Model)
  Dec 29, 2018 5:59:42 PM org.springframework.web.servlet.DispatcherServlet initServletBean
  INFO: FrameworkServlet 'MyDemoApp': initialization completed in 1751 ms
  </code></pre>
  
  <p>Experiment #3:</p>
  
  <pre><code>http://localhost:8080/springMVCDemo/getQuote2.html
  </code></pre>
  
  <p>Result: As expected here, I got HTTP 404 since no such mapping exists.  Also the following Eclipse console message was displayed:</p>
  
  <pre><code>Dec 29, 2018 6:03:21 PM org.springframework.web.servlet.PageNotFound noHandlerFound
  WARNING: No mapping found for HTTP request with URI [/springMVCDemo/getQuote2.html] in DispatcherServlet with name 'MyDemoApp'
  </code></pre>
  
  <p>In summary, I believe my controller is getting mapped correctly, but for some reason the page won't get displayed :(</p>
  
  <p><strong>Software versions I am using</strong></p>
  
  <p>Eclipse 2018-09 (4.9.0); 
  Tomcat v9.0</p>
  
  <p>If anyone can provide some troubleshooting advice, it would be greatly appreciated.  I've spent nearly 8 hours trying to tailor my servlet config file, but so far no luck.</p>