title: @ControllerAdvice is not returning json response
body: <p>Whenever my controller is throwing the exception, it is not not returning the response in json format. </p>
  
  <p>It is giving Whitelabel Error Page</p>
  
  <pre><code>This application has no explicit mapping for /error, so you are seeing this as a fallback.
  </code></pre>
  
  <p>My controller is:</p>
  
  <pre><code>@RequestMapping(value = GENERATE_IMAGE, method = RequestMethod.GET, produces = MediaType.IMAGE_PNG_VALUE)
  public byte[] get(@PathVariable("input") String input) throws IOException {
      if (true) {
          throw new BusinessValidationFailureException("sdfsdfsd");
      }
      ByteArrayInputStream inputStream = service.generate(input);
      return ByteStreams.toByteArray(inputStream);
  }
  </code></pre>
  
  <p>And my controller advice is:</p>
  
  <pre><code>@ControllerAdvice
  public class WickesGlobalExceptionMapper extends ResponseEntityExceptionHandler {
  
      @ExceptionHandler(BusinessValidationFailureException.class)
      @ResponseBody
      public ResponseEntity handleBusinessException(BusinessValidationFailureException ex, WebRequest request) {
  
          ErrorResource error = new ErrorResource("InvalidRequest", ex.getMessage(), null);
  
          HttpHeaders headers = new HttpHeaders();
          headers.setContentType(MediaType.APPLICATION_JSON);
          return handleExceptionInternal(ex, error, headers, HttpStatus.UNPROCESSABLE_ENTITY, request);
      }
  }
  </code></pre>
  
  <p>I tried few other possibility but I got the same error page all the time.</p>
  
  <p>I get below exception in the server:</p>
  
  <pre><code>org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
      at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:259) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:203) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:81) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:132) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver.doResolveHandlerMethodException(ExceptionHandlerExceptionResolver.java:384) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.web.servlet.handler.AbstractHandlerMethodExceptionResolver.doResolveException(AbstractHandlerMethodExceptionResolver.java:59) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:136) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.web.servlet.handler.HandlerExceptionResolverComposite.resolveException(HandlerExceptionResolverComposite.java:74) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
  </code></pre>