Skip to Content
1
Former Member
Jan 05, 2015 at 02:44 PM

Exception Handler with @ControllerAdvice not being called

4832 Views

Hi, Using @ControllerAdvice annotation I want to handle Runtime exceptions globally in CustomExceptionHandler class. Below is an example

 @ControllerAdvice
 public class CustomExceptionHandler
 {
 
     @ExceptionHandler(CustomExceptionHandler.class)
     public ModelAndView handleAllException(final Exception exception)
     {
         }
 }

But this exception handler is not being called when application throws exception like null pointer. Please let me know If I am missing any configuration or I should change my approach. Thanks.