Spring MVC Rest: No mapping found for HTTP request with URI [/ecommerce-api/rest/checkout] in DispatcherServlet

(probably) solved `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 & deploy it (at least during day to day programming, I guess with some robust maven script or CI Server everything will work fine too).

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:

No mapping found for HTTP request with URI [/ecommerce-api/rest/checkout] in DispatcherServlet

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.

I see one problem, you are loading up the same context file (api-dispatcher-servlet.xml) twice. Essentially a typical Spring based web application has two application contexts, the first is the ROOT application context loaded up through the ContextLoaderListener, the second is the Web application context loaded up through DispatcherServlet, in your case both these are pointing to the exact same configuration file which is api-dispatcher-servlet.xml. I would recommend you do this and see if it fixes the inconsistent behavior:

.1. Create say a applicationContext.xml file, for now it need not have any beans defined, later you can put your service related beans in this file.