title: JSON to POJO mapping in Rest
body: <p>I am new to WebServices. I was able to implement normal get and post,but when I am trying to implement post method with  MediaType.APPLICATION_JSON. I am getting errors. Please let me know what is wrong here.</p>
  
  <h2>    MY Resource :</h2>
  
  <pre><code>package com;
  import javax.ws.rs.Consumes;
  import javax.ws.rs.GET;
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  @Path("Hi")
  public class Resource {
  @GET()
  @Produces(MediaType.TEXT_HTML)
  public String x() {
      return "HI HI";
  }
  
  @POST()
  // @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.TEXT_HTML)
  public String x1() {
      return "HI HI post normal";
  }
  
  @POST()
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.TEXT_HTML)
  public String x2(Pojo p) {
      return "HI HI post jason" + p.getName();
  
  }
  
  }
  </code></pre>
  
  <p>_----------------------</p>
  
  <h2>My Web.xml</h2>
  
  <p>.......</p>
  
  <pre><code>     &lt;servlet&gt;
       &lt;servlet-name&gt;Bakchodi&lt;/servlet-name&gt;
       &lt;servlet-Class&gt;          
       com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
       &lt;init-param&gt;
       &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
       &lt;param-value&gt;com&lt;/param-value&gt;
       &lt;/init-param&gt;
       &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
   &lt;/servlet&gt;
  
   &lt;servlet-mapping&gt;
       &lt;servlet-name&gt;Bakchodi&lt;/servlet-name&gt;
       &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;`
  </code></pre>
  
  <hr>
  
  <h2>Pojo</h2>
  
  <pre><code> package com;
  
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name="someName")
  public class Pojo {
  private String name;
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public String toString() {
      return "Pojo[name =" + name + "]";
  }
  
  }
  </code></pre>
  
  <hr>
  
  <h2>Jars included in pom.xml</h2>
  
  <p>asm,jersey{core,server,client,bundle,json,}andcommon-loggings</p>
  
  <p>Please tell what I am missing.</p>
  
  <p>Error:</p>
  
  <pre><code>    status:415
      server console:SEVERE: A message body reader for Java class com.Pojo, and Java type class com.Pojo, and MIME media type application/json was not found.
      The registered message body readers compatible with the MIME media type are:
      application/json -&gt;
        com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$App
        com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App
        com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$App
      */* -&gt;
        com.sun.jersey.core.impl.provider.entity.FormProvider
        com.sun.jersey.core.impl.provider.entity.StringProvider
        com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
        com.sun.jersey.core.impl.provider.entity.FileProvider
        com.sun.jersey.core.impl.provider.entity.InputStreamProvider
        com.sun.jersey.core.impl.provider.entity.DataSourceProvider                                                           com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
        com.sun.jersey.core.impl.provider.entity.ReaderProvider
        com.sun.jersey.core.impl.provider.entity.DocumentProvider
                com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
                com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
        com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
                com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
                com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
        com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
        com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
        com.sun.jersey.core.impl.provider.entity.EntityHolderReader
                com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
                com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General        
  </code></pre>