title: @ControllerAdvice not working with proper configuration in spring 4.0.1
body: <p>I am trying to handle and respond to requests with custom error(message) using @ControllerAdvice for Rest API calls.</p>
  
  <p>Trying with configurations and setup and specified in documentations didn't worked well. Here is my code snippet</p>
  
  <p>In RestController a method has following statement</p>
  
  <pre><code>if(object==null){   
      throw new CustomGenericException("E_001", "Null error");
  }
  </code></pre>
  
  <p>The CustomGenericException class is as below</p>
  
  <pre><code>public class CustomGenericException extends RuntimeException {
  
  private static final long serialVersionUID = 1L;
  
  private String errCode;
  private String errMsg;
  
  public String getErrCode() {
      return errCode;
  }
  
  public void setErrCode(String errCode) {
      this.errCode = errCode;
  }
  
  public String getErrMsg() {
      return errMsg;
  }
  
  public void setErrMsg(String errMsg) {
      this.errMsg = errMsg;
  }
  
  public CustomGenericException(String errCode, String errMsg) {
      this.errCode = errCode;
      this.errMsg = errMsg;
  }
  }
  </code></pre>
  
  <p>The Custom exception handler class as below</p>
  
  <pre><code>@ControllerAdvice
  public class GlobalExceptionController{
  
      @ResponseStatus(value = HttpStatus.BAD_REQUEST)
      @ExceptionHandler(CustomGenericException.class)
      public @ResponseBody String handleCustomException(CustomGenericException ex) {
          System.out.println(ex.getErrCode());
          return ex.getErrMsg();
      }
  }
  </code></pre>
  
  <p>And finally i have configurations in my dispatcher-servlet.xml file as below</p>
  
  <pre><code>&lt;mvc:annotation-driven /&gt;
  &lt;context:component-scan base-package="com.xyz.pqr.controller" /&gt;
  </code></pre>
  
  <p>The issue i am facing is i am getting null when below statement is executed</p>
  
  <pre><code>throw new CustomGenericException("E_001", "Null error");
  </code></pre>