title: Spring 4 Error 415 Unsupported Media Type Error
body: <p>Running my Java code is always returning a 415 error. I'm using Spring 4.1.5 and fasterxml Jackson (core and databind) 2.5.2</p>
  
  <pre><code>@RestController
  @RequestMapping("/mainvm")
  public class MainVMController {
      @RequestMapping(value = "/init",consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
      public Map&lt;String, Object&gt; init() {...}
  }
  </code></pre>
  
  <p>The JavaScript is a simple HTTP GET:</p>
  
  <pre><code>$.ajax({
      url : "mainvm/init",
      dataType : 'json',
      headers: { 
          'Accept': 'application/json',
          'Content-Type': 'application/json' 
      }
  }).done(function() {}
  </code></pre>
  
  <p>The Spring context :</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"           xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
  xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
      http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.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-3.2.xsd"&gt;
  
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="it.staer" /&gt;
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  &lt;bean
      class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"&gt;
      &lt;property name="cacheSeconds" value="0" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- Hibernate/Jdbc Configuration --&gt;
  &lt;context:property-placeholder location="classpath:jdbc.properties" /&gt;
  
  &lt;bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
      destroy-method="close" p:driverClassName="${jdbc.driverClassName}"
      p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}" /&gt;
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;     
  &lt;/bean&gt;
  
  &lt;!-- Resolver/mapping configuration --&gt;
  
  &lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;property name="viewClass"
          value="org.springframework.web.servlet.view.JstlView" /&gt;
      &lt;property name="prefix" value="/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  &lt;mvc:resources mapping="/ui/**" location="/ui/" /&gt;
  &lt;mvc:default-servlet-handler/&gt;  
  &lt;mvc:annotation-driven /&gt;
  
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Can someone point out the problem?</p>