title: How to invoke an overridden handleMethodArgumentNotValid in a SpringBoot REST Api?
body: <p>I am struggling to invoke the overridden MethodArgumentNotValidException  in my spring boot REST api. My other exception handlers work like a charm, however overriding the standard handleMethodArgumentNotValid is never getting triggered?</p>
  <p>Anyone got a clue what I missed?</p>
  <p>Pojo</p>
  <pre><code>public class FundsConfirmationRequest {
    @NotNull(message = &quot;Required Parameter: Account Identifier.&quot;)
    private String accountId;
    @NotNull(message = &quot;Required Parameter: Transaction Amount.&quot;)
    @Digits(integer=12, fraction=5, message = &quot;Fractions limited to 5 digits.&quot;)
    private BigDecimal amount;
    @NotNull(message = &quot;Required Paramater: Currency Code.&quot;)
    @Size(min = 3, max = 3, message = &quot;Use ISO4217 Currency Code standard.&quot;)
    private String ccy;
    private String cardNumber;
    private String payee;
  
     public FundsConfirmationRequest() { } 
  }
  </code></pre>
  <p>Controller-Method:</p>
  <pre><code>@RestController(&quot;fundsConfirmationController&quot;)
  @RequestMapping(
          value=&quot;/accounts/{accountId}/funds-confirmations&quot;
  )
  public class FundsConfirmationController implements FundsConfirmationControllerI {
  
      @GetMapping(
              headers = {&quot;X-CAF-MSGID&quot;, &quot;X-AccessToken&quot;},
              consumes = MediaType.APPLICATION_JSON_VALUE,
              produces = MediaType.APPLICATION_JSON_VALUE
      )
      public ResponseEntity&lt;?&gt; fundsConfirmation(@RequestHeader(value=&quot;X-CAF-MSGID&quot;) String messageId,
                                                 @RequestHeader(value=&quot;X-AccessToken&quot;) String accessToken,
                                                 @Valid FundsConfirmationRequest requestParams) throws FIClientException, FIParseException {
  </code></pre>
  <p>Exception handler via @RestControllerAdvice</p>
  <pre><code>@RestControllerAdvice
  public class FundsConfirmationExceptionHandler extends ResponseEntityExceptionHandler {
  
      //Existing Exception Handlers
      @Override
      public ResponseEntity&lt;Object&gt; handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
          System.out.println(&quot;Custom handleMethodArgumentNotValid method&quot;);
          FundsConfirmationError responseBody = new FundsConfirmationError(HttpStatus.BAD_REQUEST.toString(), &quot;Input Validation Failed. Parameter.: &quot; + ex.getParameter().getParameterName() + &quot; Value.: &quot; + ex.getParameter().getParameter().toString() + &quot; &quot; + ex.getMessage(), Severity.ERROR.toString(), Sources.LOCAL_CAF_API.toString() );
          return ResponseEntity
                  .status(HttpStatus.BAD_REQUEST)
                  .header(&quot;X-CAF-ResponseID&quot;, request.getHeader(&quot;X-CAF-MSGID&quot;))
                  .body(responseBody);
      }
  </code></pre>