title: Spring MVC rest service not accessible on Google App Engine
body: <p>I am using Spring MVC to expose some rest services. I have exposed them in this manner:</p>
  
  <pre><code>@RestController
  @RequestMapping("/testpath")
  public class ConcreteMyController implements MyController {
  
      @RequestMapping(method = RequestMethod.GET)
      @ResponseStatus(value = HttpStatus.OK)
      @Override
      public String testGet(@RequestBody HttpServletRequest req, HttpServletResponse resp) {
          return "here is a string";
      }
  }
  </code></pre>
  
  <p>After deploying on Google App Engine I notice that I cannot access <a href="https://mydomain.appspot.com/testpath" rel="nofollow noreferrer">https://mydomain.appspot.com/testpath</a> without getting a 404 error.</p>
  
  <p>I tried changing it to a HttpServlet and then it is working like this:</p>
  
  <pre><code>public class ConcreteMyController extends HttpServlet  {
  
      @Override
      public String doGet(HttpServletRequest req, HttpServletResponse resp)  {
          PrintWriter respWriter = resp.getWriter();
          resp.setStatus(200);
          resp.setContentType("text/html");
          respWriter.println("here is a string");
  
      }
  }
  </code></pre>
  
  <p>The web.xml looks like this:</p>
  
  <p>
  </p>
  
  <pre><code>&lt;web-app&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/mvc-dispatcher-servlet.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;CORS&lt;/filter-name&gt;
          &lt;filter-class&gt;com.thetransactioncompany.cors.CORSFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;CORS&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;dispatcher&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;&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
  
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;testservlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;package.ConcreteMyController&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;PlusSampleServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/plussampleservlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;security-constraint&gt;
          &lt;web-resource-collection&gt;
              &lt;web-resource-name&gt;any&lt;/web-resource-name&gt;
              &lt;url-pattern&gt;/anotherpathIamusing&lt;/url-pattern&gt;
          &lt;/web-resource-collection&gt;
          &lt;auth-constraint&gt;
              &lt;role-name&gt;*&lt;/role-name&gt;
          &lt;/auth-constraint&gt;
      &lt;/security-constraint&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>My mvc-dispatcher-servlet.xml looks like this:</p>
  
  <pre><code>&lt;beans xmlns:context="http://www.springframework.org/schema/context"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://www.springframework.org/schema/beans"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  
  
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.2.xsd"&gt;
  
      &lt;context:component-scan base-package="package.config"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>In the config package I have a file looking like this:</p>
  
  <pre><code>@EnableWebMvc
  @EnableScheduling
  @EnableTransactionManagement
  @EnableJpaRepositories("package.model.repository")
  @ComponentScan("package")
  @Configuration
  public class AppConfig {
      //Omitted datasources
  }
  </code></pre>
  
  <p>The Spring MVC code has been working before I made this a Google App Engine project. Now I have to use a HttpServlet to expose services. How do I make the Spring MVC option work? Help would be greatly appreciated.</p>
  
  <p>NOTE: Regarding the web.xml, I have posted the code for both with and without Spring MVC. When testing I am only using one of them.</p>