title: Spring MVC Rest: No mapping found for HTTP request with URI [/ecommerce-api/rest/checkout] in DispatcherServlet
body: <p><strong>(probably) solved</strong> `or at least it seems to be. I'm not really sure where it was the problem. For sure the config suggested by Biju Kunjummen, it's working and seems to me cleaner. What I'm doing now, to not generate mess is to work only inside Eclipse, sometimes cleaning the projects and never using maven to package &amp; deploy it (at least during day to day programming, I guess with some robust maven script or CI Server everything will work fine too). </p>
  
  <p>I'm trying to setup a Rest API with Spring MVC. I've read a lot of documentation but I'm still getting the error in the subject:</p>
  
  <blockquote>
    <p>No mapping found for HTTP request with URI [/ecommerce-api/rest/checkout] in DispatcherServlet</p>
  </blockquote>
  
  <p>The problem is exactly the same reported (and solved) in other similar questions, like this one <a href="https://stackoverflow.com/questions/15163035/fixed-no-mapping-found-trying-to-set-up-a-restfull-interface-using-spring-mvc">FIXED: &quot;No mapping found&quot; Trying to set up a RESTfull interface using Spring-MVC</a></p>
  
  <p>The really strange thing is that, without apparently changing anything in my code, sometime it works and sometimes it doesn't. I'm pretty sure nothing changes between the two moments, since for example sometime I'm physically away  then I come back and it stops working.</p>
  
  <p>At this particular moment, my code is the following:</p>
  
  <p>web.xml</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" 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"&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/api-dispatcher-servlet.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;api-dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
          org.springframework.web.servlet.DispatcherServlet
      &lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;api-dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;
          org.springframework.web.context.ContextLoaderListener
      &lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;
          org.springframework.web.context.request.RequestContextListener
      &lt;/listener-class&gt;
  &lt;/listener&gt;
  
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>api-dispatcher-servlet.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:util="http://www.springframework.org/schema/util"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc 
      http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
      http://www.springframework.org/schema/util 
      http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
      &lt;context:component-scan base-package="com.myapp.api.ecommerce.controller" /&gt;
      &lt;context:annotation-config /&gt;
      &lt;mvc:annotation-driven /&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>com.myapp.ecommerce.controller.CheckoutController</p>
  
  <pre><code>package com.myapp.api.ecommerce.controller;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  import com.myapp.ecommerce.service.checkout.manager.CheckoutManager;
  import com.myapp.ecommerce.service.checkout.manager.CheckoutManagerImpl;
  import com.myapp.ecommerce.service.checkout.model.Checkout;
  
  
  @Controller
  @RequestMapping("/checkout")
  public class CheckoutController {
  
  
      private CheckoutManager checkoutManager = new CheckoutManagerImpl();
  
      @RequestMapping(method = RequestMethod.GET)
      public @ResponseBody Checkout getCheckout() {
  
              return checkoutManager.findById("514f2a8e20f7a78a1400001f");
      }
  
  
  }
  </code></pre>
  
  <p>A snippet of the log file of the application server (VFabric but I've also tried with Tomcat 7) when I try to <em>GET ecommerce-api/rest/checkout</em>:</p>
  
  <pre><code>2013-09-05 22:31:37,760 DEBUG [tomcat-http--5] servlet.DispatcherServlet (DispatcherServlet.java:823) - DispatcherServlet with name 'api-dispatcher' processing GET request for [/ecommerce-api/rest/checkout]
  2013-09-05 22:31:37,763 DEBUG [tomcat-http--5] handler.AbstractHandlerMethodMapping (AbstractHandlerMethodMapping.java:220) - Looking up handler method for path /checkout
  2013-09-05 22:31:37,763 DEBUG [tomcat-http--5] handler.AbstractHandlerMethodMapping (AbstractHandlerMethodMapping.java:230) - Did not find handler method for [/checkout]
  2013-09-05 22:31:37,764 WARN  [tomcat-http--5] servlet.DispatcherServlet (DispatcherServlet.java:1108) - No mapping found for HTTP request with URI [/ecommerce-api/rest/checkout] in DispatcherServlet with name 'api-dispatcher'
  2013-09-05 22:31:37,764 DEBUG [tomcat-http--5] servlet.FrameworkServlet (FrameworkServlet.java:966) - Successfully completed request
  </code></pre>
  
  <p>I really don't know what to do since it worked since last time I shut down my Mac and until that moment I thought to know how to do it.</p>