title: @ControllerAdvice doesn't handle exceptions
body: <p>I am using Spring Boot 1.5.9 for developing my application. I need implement jwt authentication, and I used jjwt library. The following code is from my custom authentication security filter which inherits from <code>OncePerRequestFilter</code>. Here I tried to parse the username from token, when username is parsing automatically is jwt verified and also check expiration of token. I debug it and it works, so I next want to send the correct message to the client app why authentication failed. I want to throw an ExpiredJwtException and handle it with the controller advice where I format the output.</p>
  
  <p>Here is exception throwing:</p>
  
  <pre><code>try {
      username = jwtTokenService.getUsername(authToken);
  } catch (IllegalArgumentException e) {
      logger.error("an error occured during getting username from token", e);
  } catch (ExpiredJwtException e) {
      logger.warn("the token is expired and not valid anymore", e);
      throw new ExpiredJwtException(e.getHeader(), e.getClaims(), e.getMessage());
  }
  </code></pre>
  
  <p>And here is my controller Advice, JwtException is base class of ExpiredJwtException which I throw so it should work. I also tried directly use ExpiredJwtException in ExceptionHandler, but didn't work as well. Next I want to handle another exceptions with same way.</p>
  
  <pre><code>@ControllerAdvice
  public class GlobalControllerExceptionHandler {
  
      @ExceptionHandler(Exception.class)
      public @ResponseBody
      ResponseEntity&lt;Map&lt;String, Object&gt;&gt; handleException(Exception ex) {
          Map&lt;String, Object&gt; errorInfo = new HashMap&lt;&gt;();
          errorInfo.put("message", ex.getMessage());
          errorInfo.put("status", HttpStatus.BAD_REQUEST);
          errorInfo.put("status_code", HttpStatus.BAD_REQUEST.value());
          return new ResponseEntity&lt;&gt;(errorInfo, HttpStatus.BAD_REQUEST);
      }
  
  
      @ExceptionHandler(JwtException.class)
      //@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY)
      public @ResponseBody
      ResponseEntity handleJwtException(JwtException ex) {
          Map&lt;String, Object&gt; errorInfo = new HashMap&lt;&gt;();
          errorInfo.put("message", ex.getLocalizedMessage());
          errorInfo.put("status", HttpStatus.UNPROCESSABLE_ENTITY);
          errorInfo.put("status_code", HttpStatus.UNPROCESSABLE_ENTITY.value());
          return new ResponseEntity&lt;&gt;(errorInfo, HttpStatus.UNPROCESSABLE_ENTITY);
      }
  
  }
  </code></pre>
  
  <p>Here is my folder structure:
  <a href="https://i.stack.imgur.com/m4Xyi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m4Xyi.png" alt="enter image description here"></a></p>
  
  <p>I want return just response with 4xx status, but I always got 5xx Internal error when my exception is thrown. Can you tell me what is wrong with my code? Thanks in advice.</p>