title: Java Spring - 415 Unsupported Media Type
body: <p>Here is my Controller:</p>
  
  <pre><code>@RestController
  public class UserController {
  
      @RequestMapping(value = "/test", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
      public User someName(@RequestBody  User user){
          System.out.println(user.toString());
          return user;
      }
  
  }
  </code></pre>
  
  <p>User class:</p>
  
  <pre><code>@Entity
  @Table(name = "user")
  public class User {
  
      @Id @GeneratedValue
      @Column(name = "id")
      private Integer id;
  
      private String name;
      private String secondname;
      private String email;
  
      public User() {
      }
  
      public User(Integer id, String name, String secondname, String email) {
          this.id = id;
          this.name = name;
          this.secondname = secondname;
          this.email = email;
      }
  
      public User(String name, String secondname, String email) {
          this.name = name;
          this.secondname = secondname;
          this.email = email;
      }
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      @Column(name = "name")
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @Column(name = "secondname")
      public String getSecondname() {
          return secondname;
      }
  
      public void setSecondname(String secondname) {
          this.secondname = secondname;
      }
  
      @Column(name = "email")
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      @Override
      public String toString() {
          return new StringBuilder().append(this.name).append(", ").append(this.secondname).append(", ")
                  .append(this.email).toString();
      }
  }
  </code></pre>
  
  <p>And my pom.xml:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;pl&lt;/groupId&gt;
    &lt;artifactId&gt;javalab&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;javalab Maven Webapp&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
         &lt;java-version&gt;1.7&lt;/java-version&gt;
     &lt;/properties&gt;
  
     &lt;repositories&gt;
         &lt;!-- Repository for ORACLE JDBC Driver --&gt;
         &lt;repository&gt;
             &lt;id&gt;codelds&lt;/id&gt;
             &lt;url&gt;https://code.lds.org/nexus/content/groups/main-repo&lt;/url&gt;
         &lt;/repository&gt;
     &lt;/repositories&gt;
  
     &lt;dependencies&gt;
  
         &lt;dependency&gt;
             &lt;groupId&gt;junit&lt;/groupId&gt;
             &lt;artifactId&gt;junit&lt;/artifactId&gt;
             &lt;version&gt;3.8.1&lt;/version&gt;
             &lt;scope&gt;test&lt;/scope&gt;
         &lt;/dependency&gt;
  
         &lt;!-- Servlet API --&gt;
         &lt;!-- http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
             &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
             &lt;version&gt;3.1.0&lt;/version&gt;
             &lt;scope&gt;provided&lt;/scope&gt;
         &lt;/dependency&gt;
  
         &lt;!-- Jstl for jsp page --&gt;
         &lt;!-- http://mvnrepository.com/artifact/javax.servlet/jstl --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
             &lt;artifactId&gt;jstl&lt;/artifactId&gt;
             &lt;version&gt;1.2&lt;/version&gt;
         &lt;/dependency&gt;
  
  
         &lt;!-- JSP API --&gt;
         &lt;!-- http://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
             &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
             &lt;version&gt;2.2&lt;/version&gt;
             &lt;scope&gt;provided&lt;/scope&gt;
         &lt;/dependency&gt;
  
         &lt;!-- Spring dependencies --&gt;
         &lt;!-- http://mvnrepository.com/artifact/org.springframework/spring-core --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;org.springframework&lt;/groupId&gt;
             &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
             &lt;version&gt;4.1.4.RELEASE&lt;/version&gt;
         &lt;/dependency&gt;
  
         &lt;!-- http://mvnrepository.com/artifact/org.springframework/spring-web --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;org.springframework&lt;/groupId&gt;
             &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
             &lt;version&gt;4.1.4.RELEASE&lt;/version&gt;
         &lt;/dependency&gt;
  
         &lt;!-- http://mvnrepository.com/artifact/org.springframework/spring-webmvc --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;org.springframework&lt;/groupId&gt;
             &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
             &lt;version&gt;4.1.4.RELEASE&lt;/version&gt;
         &lt;/dependency&gt;
  
         &lt;!-- http://mvnrepository.com/artifact/org.springframework/spring-orm --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;org.springframework&lt;/groupId&gt;
             &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
             &lt;version&gt;4.1.4.RELEASE&lt;/version&gt;
         &lt;/dependency&gt;
  
         &lt;!-- Hibernate --&gt;
         &lt;!-- http://mvnrepository.com/artifact/org.hibernate/hibernate-core --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
             &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
             &lt;version&gt;4.3.8.Final&lt;/version&gt;
         &lt;/dependency&gt;
  
         &lt;!-- http://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
             &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
             &lt;version&gt;4.3.8.Final&lt;/version&gt;
         &lt;/dependency&gt;
  
  
         &lt;!-- http://mvnrepository.com/artifact/org.hibernate/hibernate-c3p0 --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
             &lt;artifactId&gt;hibernate-c3p0&lt;/artifactId&gt;
             &lt;version&gt;4.3.8.Final&lt;/version&gt;
         &lt;/dependency&gt;
  
  
         &lt;!-- MySQL JDBC driver --&gt;
         &lt;!-- http://mvnrepository.com/artifact/mysql/mysql-connector-java --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;mysql&lt;/groupId&gt;
             &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
             &lt;version&gt;5.1.34&lt;/version&gt;
         &lt;/dependency&gt;
  
         &lt;!-- Oracle JDBC driver --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;com.oracle&lt;/groupId&gt;
             &lt;artifactId&gt;ojdbc6&lt;/artifactId&gt;
             &lt;version&gt;11.2.0.3&lt;/version&gt;
         &lt;/dependency&gt;
  
         &lt;!-- SQLServer JDBC driver (JTDS) --&gt;
         &lt;!-- http://mvnrepository.com/artifact/net.sourceforge.jtds/jtds --&gt;
         &lt;dependency&gt;
             &lt;groupId&gt;net.sourceforge.jtds&lt;/groupId&gt;
             &lt;artifactId&gt;jtds&lt;/artifactId&gt;
             &lt;version&gt;1.3.1&lt;/version&gt;
         &lt;/dependency&gt;
  
          &lt;!-- Mail Start --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.mail&lt;/groupId&gt;
              &lt;artifactId&gt;mail&lt;/artifactId&gt;
              &lt;version&gt;1.4.7&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
              &lt;version&gt;4.1.4.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Mail End --&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.8.7&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.dataformat&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-dataformat-xml&lt;/artifactId&gt;
              &lt;version&gt;2.8.7&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &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.8.7&lt;/version&gt;
          &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
    &lt;build&gt;
      &lt;finalName&gt;javalab&lt;/finalName&gt;
      &lt;plugins&gt;
             &lt;plugin&gt;
                 &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
                 &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
                 &lt;version&gt;2.2&lt;/version&gt;
             &lt;/plugin&gt;
         &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>When I want to post in in postman:</p>
  
  <pre><code>{
      "name": "test",
      "secondname": "test",
      "email": "test@test.pl"
  }
  </code></pre>
  
  <p>I have an error: <code>415 Unsupported Media type</code>
  More precisely I have: <code>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.</code></p>
  
  <p>In postman I choose <code>raw</code> and <code>JSON (application/json)</code>. As headers I have written: <code>Content-Type</code> as key and <code>application/json</code> as value.</p>
  
  <p>Somebody have any idea what I'm doing wrong?</p>