title: Spring 4.0 REST call results in 406 error code
body: <p>My REST calls to a simple controller i have setup always comes back with a 406 (not acceptable) response code.
  My request header has Accept: 'application/json' and
  I also have jackson libraries in my classpath</p>
  
  <p>Spring version used 4.0.6 (I also tried 4.0.5).
  App Server  Tomcat 8</p>
  
  <p>My class </p>
  
  <pre><code>@RestController
  @RequestMapping("/menu")
  public class TestController extends AbstractController {
  
  
      @RequestMapping(method = RequestMethod.GET, value = "/config")
      public Map getConfig (final HttpServletRequest request)
      {
          return new HashMap();
      }
  
  }
  </code></pre>
  
  <p>I also tried changing my method annotation to:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.GET, value = "/config", produces={"application/json"})
  </code></pre>
  
  <p>My Spring web context file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:util="http://www.springframework.org/schema/util"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="
         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.xsd
         http://www.springframework.org/schema/tx
         http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
         http://www.springframework.org/schema/util
         http://www.springframework.org/schema/util/spring-util.xsd
         http://www.springframework.org/schema/mvc
         http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"&gt;
  
      &lt;mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/&gt;
  
      &lt;bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"&gt;
          &lt;property name="defaultContentType" value="application/xml" /&gt;
          &lt;property name="mediaTypes"&gt;
              &lt;map&gt;
                  &lt;entry key="json" value="application/json"/&gt;
              &lt;/map&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>I also tried with a simple</p>
  
  <pre><code>&lt;mvc:annotation-driven/&gt;
  </code></pre>
  
  <p>tag and without the contentNegotiationManager bean. The application starts both ways and the method on the server is called, but i get the 406 response everytime.</p>
  
  <p>Client request Headers:</p>
  
  <pre><code>Host: 127.0.0.1:8002
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
  Accept: application/json,application/xml
  Accept-Language: en-US,en;q=0.5
  Accept-Encoding: gzip, deflate
  Content-Type: application/json
  X-Requested-With: XMLHttpRequest
  Referer: http://127.0.0.1:8002/myapp/login.rest
  Cookie: JSESSIONID=431505385C0E8A5AAC878BA2B8AE1F92; 
  Connection: keep-alive
  </code></pre>
  
  <p>Jackson libraries used and in my classpath:</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
              &lt;version&gt;2.4.3&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
              &lt;version&gt;2.4.3&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
              &lt;version&gt;1.9.13&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
              &lt;version&gt;2.4.3&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>I also tried using the jackson 2.3.3 libraries.</p>
  
  <p>Running a simple Spring boot example with an annotation only example works fine. I'm not sure what i am missing here.</p>
  
  <p>Most of the other Spring 406 issues here on Stackoverflow seem to have to do with missing jackson libraries or incorrect request headers, both of which i have.</p>
  
  <p>I think my spring web context file is missing something. But i was under the impression that Spring should handle converting my response to JSON automatically.
  Any ideas on what i am missing here?</p>
  
  <p>In all my attempts, the server code is called but the response is 406 every time.</p>