title: @NotNull : validation custom message not displaying
body: <p>I am using spring data JPA for creating application. In that I am trying to implement server side validation using annotation. I added <code>@NotNull</code> annotation on filed with custom message. I also added <code>@valid</code> with <code>@RequestBody</code> </p>
  
  <p>But problem is that when I am passing <code>nAccountId</code> as <code>null</code> I am not getting custom message i.e. <code>Account id can not be null</code> I am getting "message": <code>"Validation failed for object='accountMaintenanceSave'. Error count: 1",</code>.</p>
  
  <p>Can any one please tell me why I am not getting custom message?</p>
  
  <p><strong>Controller code</strong></p>
  
  <pre><code>@PutMapping("/updateAccountData")
  public ResponseEntity&lt;Object&gt; saveData(@Valid @RequestBody AccountMaintenanceSave saveObj){
      return accService.saveData(saveObj);
  } 
  </code></pre>
  
  <p><strong>AccountMaintenanceSave class</strong>  </p>
  
  <pre><code>import javax.validation.constraints.NotNull;
  
  public class AccountMaintenanceSave {   
  
      @NotNull(message="Account id can not be null")
      public Integer nAccountId;
      @NotNull
      public String sClientAcctId;
      @NotNull
      public String sAcctDesc;
      @NotNull
      public String sLocation;
      @NotNull
      public Integer nDeptId; 
      @NotNull
      public Integer nAccountCPCMappingid;
      @NotNull
      public Integer nInvestigatorId;
  
      //Getter and Setter
  }
  </code></pre>
  
  <p><strong>RestExceptionHandler class</strong></p>
  
  <pre><code>@ControllerAdvice
  public class RestExceptionHandler { 
  
      @ExceptionHandler(Exception.class)
      public ResponseEntity&lt;Object&gt; handleAllExceptionMethod(Exception ex, WebRequest requset) {
  
          ExceptionMessage exceptionMessageObj = new ExceptionMessage();
  
          exceptionMessageObj.setMessage(ex.getLocalizedMessage());
          exceptionMessageObj.setError(ex.getClass().getCanonicalName());
          exceptionMessageObj.setPath(((ServletWebRequest) requset).getRequest().getServletPath());
  
          // return exceptionMessageObj;
          return new ResponseEntity&lt;&gt;(exceptionMessageObj, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR);
      }
  }
  </code></pre>
  
  <p>I don't know what exactly happen previously and not getting proper message. Now using same code getting result like this with proper message</p>
  
  <pre><code>{
    "message": "Validation failed for argument at index 0 in method: public org.springframework.http.ResponseEntity&lt;java.lang.Object&gt; com.spacestudy.controller.AccountController.saveData(com.spacestudy.model.AccountMaintenanceSave), with 1 error(s): [Field error in object 'accountMaintenanceSave' on field 'nAccountId': rejected value [null]; codes [NotNull.accountMaintenanceSave.nAccountId,NotNull.nAccountId,NotNull.java.lang.Integer,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [accountMaintenanceSave.nAccountId,nAccountId]; arguments []; default message [nAccountId]]; default message [Account id can not be null]] ",
    "error": "org.springframework.web.bind.MethodArgumentNotValidException",
    "path": "/spacestudy/rockefeller/admin/account/updateAccountData"
  }
  </code></pre>
  
  <p>In <code>message</code> filed can I print only  <code>[Account id can not be null]</code>?</p>