title: Unable to send JSON object to Rest web service
body: <p>I have a REST web servce configure as the following:</p>
  
  <pre><code>@Path("/users")
  public class UserManager {
  
  @Context
  UriInfo uriInfo;
  
  @POST
  @Consumes("application/json")
  public void createUser(User user) {
      URI uri = uriInfo.getAbsolutePathBuilder().path(user.getUserName())
              .build();
      Response res = Response.created(uri).build();
      try {
          MongoDbDataAccess.getInstance().addUser(user);
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>And My Tomcat server configure as the following:</p>
  
  <pre><code>&lt;servlet&gt;
    &lt;servlet-name&gt;Jersey REST Service&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;anyq.server.anyq.manager&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;Jersey REST Service&lt;/servlet-name&gt;
     &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>The POJO I create look like the following:</p>
  
  <pre><code>@XmlRootElement
  public class User {
  
  private long userId;
  private String userName;
  private String userPassword;
  
  public User() {
      super();
  }
  
  public User(long userId, String userName, String userPassword) {
      super();
      this.userId = userId;
      this.userName = userName;
      this.userPassword = userPassword;
  }
  
  public long getUserId() {
      return userId;
  }
  
  public void setUserId(long userId) {
      this.userId = userId;
  }
  
  public String getUserName() {
      return userName;
  }
  
  public void setUserName(String userName) {
      this.userName = userName;
  }
  
  public String getUserPassword() {
      return userPassword;
  }
  
  public void setUserPassword(String userPassword) {
      this.userPassword = userPassword;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I create the a test client in order to test the createUser method:</p>
  
  <pre><code>public class tester {
  
  public static void main(String[] args) throws UnknownHostException {
  
      String USER_URI = "http://localhost:8080/AnyAppserver/rest/users";
      User user = new User((long) 451, "mosssi", "464asd64");
  
      Client client = Client.create();
  
      WebResource r = client.resource(USER_URI);
  
      ClientResponse response = r.accept(MediaType.APPLICATION_JSON).post(
              ClientResponse.class, user);
  
  
  }
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <pre><code>POST http://localhost:8080/AnyAppserver/rest/users returned a response status of 415 Unsupported Media Type
  </code></pre>
  
  <p>The wierd issue is when I change everything to appliction/xml  it work perfectly</p>
  
  <p>Any Idea why Json doesnt work for me?</p>