title: FileSystemResource as ResponseBody in spring rest controller gives ClassCastException
body: <p>I have defined a controller which serves local content like this:</p>
  
  <pre><code>@RequestMapping(value = PATH_CONTENT, method = RequestMethod.GET)
  @ResponseBody
  public ResponseEntity&lt;FileSystemResource&gt; getContent(
      @PathVariable(URI_PATH_PARAM_CONTAINER_UID) String containerUid,
      @PathVariable(URI_PATH_PARAM_DOC_UID) String docUid) {
      ...
  }
  </code></pre>
  
  <p>In the client side:
  I am adding ResourceHttpMessageConverter to RestTemplate messageConverters.
  When I finally make the following call:</p>
  
  <pre><code>ResponseEntity&lt;FileSystemResource&gt; response = getMyRestClient()
          .getContent(url, null, FileSystemResource.class);
  FileSystemResourcecontent = response.getBody();
  </code></pre>
  
  <p>This produces a <code>ClassCastException</code> saying it cant cast <code>ByteArrayResource</code> to <code>FileSystemResource</code>.</p>
  
  <p>I can do some modification to my code to return a <code>Resource</code> instead of <code>FileSystemResource</code> and things will work. But I am really wondering why is this exception? I also don't want to take the path of writing to <code>HttpServletResponse</code> directly as I want to use Spring's <code>HttpMessageConverter</code> framework.</p>