title: @ControllerAdvice exception handler method not get called
body: <p>I am working on sample demo application for Exception Handling in Spring MVC.I am trying <code>Exception Handling With @ControllerAdvice</code></p>
  
  <p>I followed steps as describe in <a href="http://www.baeldung.com/2013/01/31/exception-handling-for-rest-with-spring-3-2/" rel="noreferrer">this</a> link.</p>
  
  <p>But when i run my application i get the following error</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.test.core.ApplicationException
  </code></pre>
  
  <p>For more details following are the classes I am working on </p>
  
  <p><strong>ApplicationException.java</strong></p>
  
  <pre><code>public class ApplicationException extends RuntimeException{
  
  
  /**
   * 
   */
  private static final long serialVersionUID = -9061684361606685158L;
  private ErrorStatus errorStatus;
  private int msgNumber;
  private Object []args;
  
  public ApplicationException(){}
  
  public ApplicationException(ErrorStatus errorStatus, int msgNumber,
          Object[] args) {
      this.errorStatus = errorStatus;
      this.msgNumber = msgNumber;
      this.args = args;
    }
      //getter setters
  }
  </code></pre>
  
  <p>Controller class</p>
  
  <p><strong>ApplicationExceptionController.java</strong></p>
  
  <pre><code> @Controller
  @RequestMapping("/exception")
  public class ApplicationExceptionController {
  
  @RequestMapping(value="/error",method=RequestMethod.GET)
  @ResponseBody
  public void helloException() 
  {
      throw new ApplicationException(ErrorStatus.NotFound,1,new Object[]{"Website"});
  
    //here ErrorStatus is a enum class
  }  
  }
  </code></pre>
  
  <p>And here is the GlobalExceptionHandler class</p>
  
  <p><strong>GlobalExceptionHandler.java</strong></p>
  
  <pre><code>@ControllerAdvice
  public class GlobalExceptionHandler {
  
  @ExceptionHandler
  public void notFount(){
      System.out.println("----------CaughtApplicationException-----------");
  }
  }
  </code></pre>
  
  <p><strong>dispatcher-servlet.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:tx="http://www.springframework.org/schema/tx"  
  xmlns:p="http://www.springframework.org/schema/p"      
  xmlns:context="http://www.springframework.org/schema/context"  
  xmlns:mvc="http://www.springframework.org/schema/mvc" 
  
  xsi:schemaLocation=
      "http://www.springframework.org/schema/beans     
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/mvc
      http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
      http://www.springframework.org/schema/tx
      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"&gt;
  
  
  &lt;context:component-scan  base-package="com.test.controller,com.test.core" /&gt;
  &lt;mvc:annotation-driven /&gt;
  
  &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;  
      &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;  
      &lt;property name="suffix" value=".jsp" /&gt;   
  &lt;/bean&gt;  
  
   &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
      &lt;property name="messageConverters"&gt;
       &lt;list&gt; &lt;ref bean="jsonConverter"/&gt;&lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&gt;
       &lt;property name="supportedMediaTypes" value="application/json" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>I run above application with       <a href="http://localhost:8080/SpringExceptionHandling/exception/error" rel="noreferrer">http://localhost:8080/SpringExceptionHandling/exception/error</a> this url</p>
  
  <p>But I get the following Exception</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.test.core.ApplicationException
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  
  root cause
  
  com.test.core.ApplicationException
  com.test.controller.ApplicationExceptionController.helloException(ApplicationExceptionController.java:19)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  java.lang.reflect.Method.invoke(Unknown Source)
  org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
  org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
  org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565)
  org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  </code></pre>
  
  <p>I go through <a href="https://stackoverflow.com/questions/16582411/controlleradvice-exception-handler-method-are-not-get-called#">@ControllerAdvice exception handler method are not get called</a> this link but still stuck with the same problem
  Please help me to get the solution.I am not getting the actual cause for this exception.</p>