title: Angular JS POST request map to DTO in REST Services
body: <p>I am new to Angular JS and REST services and just trying hello world.</p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;servlet&gt;
          &lt;servlet-name&gt;jersey-helloworld-serlvet&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.ipocc.service&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;
  </code></pre>
  
  <p>REST SERVICE CLASS</p>
  
  <pre><code>@Path("/UserManager")
  public class UserManagerService {
  
      @POST
      @Path("/validate")
      @Consumes({ MediaType.APPLICATION_JSON } )
      public Response responseMsg1(final User user) {
          System.out.println("POST :" + user + " " + user.getUserName() + " "  + user.getPassword());
          return Response.status(200).entity("output").build();
      }
  }
  </code></pre>
  
  <p>DTO</p>
  
  <pre><code>@XmlRootElement
  public class User {
       @XmlElement public String email;
       @XmlElement public String name;
       @XmlElement public String username;
       //GETTER-SETTER 
  }
  </code></pre>
  
  <p>ANGULAR JS FILE</p>
  
  <pre><code>var validationApp = angular.module('validationApp', []);
  validationApp.controller('mainController', function($scope,$http) {
      $scope.submitForm = function() {
  
              var update_path = "http://localhost:8080/IPOCCService/rest/UserManager/validate";
              var data1 = angular.toJson($scope.user);
              alert(data1);            
              $http({
                    url: update_path, 
                    method: "POST",
                    data:  data1,
                    headers : {
                           "Content-Type" : "application/json; charset=utf-8",
                           "Accept" : "application/json"
                     }
               }).
               success(function(data, status, headers, config) {
                   alert("success");
               }).
               error(function(data, status, headers, config) {
                   alert("failure");
               });
  
      };
  });
  </code></pre>
  
  <p>ERROR I AM FACING</p>
  
  <pre><code>SEVERE: A message body reader for Java class com.ipocc.service.dto.User, and Java type class com.ipocc.service.dto.User, and MIME media type application/json; charset=UTF-8 was not found.
  The registered message body readers compatible with the MIME media type are:
  */* -&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.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
  </code></pre>
  
  <p>I want to achieve the when I call http post request from Angular JS, it should get map to user object but I am getting error above. If I keep parameter as String then I am getting data as <code>email:"a@a.com",name: "j",username: "j"</code></p>