title: Spring Error Controller response with Not Acceptable
body: <p>I have build an error controller that should be the "last line" for catching exceptions within my Spring REST service. However it seems that I can't return POJOs as response type. Why does Jackson not working for this case?</p>
  
  <p>My Class looks like:</p>
  
  <pre><code>@RestController
  public class CustomErrorController implements ErrorController
  {
    private static final String PATH = "/error";
  
    @Override
    public String getErrorPath()
    {
       return PATH;
    }
  
  
    @RequestMapping (value = PATH)
    public ResponseEntity&lt;WebErrorResponse&gt; handleError(HttpStatus status, HttpServletRequest request)
    {
       WebErrorResponse response = new WebErrorResponse();
  
      // original requested URI
      String uri = String.valueOf(request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI));
      // status code
      String code = String.valueOf(request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE));
      // status message
      String msg = String.valueOf(request.getAttribute(RequestDispatcher.ERROR_MESSAGE));
  
      response.title = "Internal Server Error";
      response.type = request.getMethod() + ": " + uri;
      response.code = Integer.valueOf(code);
      response.message = msg;
  
      // build headers
      HttpHeaders headers = new HttpHeaders();
  
      headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
  
      // build the response
      return new ResponseEntity&lt;&gt;(response, headers, status);
  }
  
  public class WebErrorResponse
  {
  /**
   * The error message.
   */
  public String message;
  
  /**
   * The status code.
   */
  public int code;
  
  /**
   * The error title.
   */
  public String title;
  
  /**
   * The error type.
   */
  public String type;
  }
  </code></pre>
  
  <p>This should work but the only response is a Jetty Error Message with 
  406 - Not Acceptable.</p>
  
  <p>Changing the the response entity body type to String works perfect.
  Whats wrong? Maybe this is a bug?</p>
  
  <p>P.S: Working with Spring 4.2.8, Spring Boot 1.3.8.</p>