title: REST - Server Throwing Exception when Mapping JSON Request with Extra Undefined Parameters to Java Object
body: <p>I'm using a RESTFUL J2EE Web Server; when my method in a resource class is consuming JSON and a there is a JSON request with extra parameters which are not defined in my java mapping object, the server throws exception.<br>The problem is: <strong>I DON'T WANT THE SERVER TO THROW EXCEPTION!</strong> - I just want the server to ignore the request and return an error code like '400 Bad Request'!</p>
  
  <p>My method:</p>
  
  <pre><code>@POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response createUser(final UserCreateRequest request) {
      return request.getHandler().handle();
  }
  </code></pre>
  
  <p>My Simplified Java Class:</p>
  
  <pre><code>public final class UserCreateRequest extends BaseRequest {
      @JsonProperty("username")
      private String username;
  
      @JsonProperty("password")
      private String password;
  
      public final String getUsername() {
          return username;
      }
  
      public final void setUsername(String username) {
          this.username = username.trim().toLowerCase();
      }
  
      public final String getPassword() {
          return password;
      }
  
      public final void setPassword(String password) {
          this.password = password.trim();
      }
  
      @Override
      @JsonIgnore
      public BaseRequestHandler getHandler() {
          return new UserCreateHandler(this);
      }
  }
  </code></pre>
  
  <p>Sample wrong JSON request:</p>
  
  <pre><code>{
       username: "test",
       password: "1234",
       name: "hello"
  }
  </code></pre>
  
  <p>In this sample the parameter 'name' is undefined!</p>