Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-165

MIME type image/gif doesn't work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • RC 1
    • Beta 9
    • None
    • None

      The following method produces the stacktrace at the bottom:

      @GET
      @Path("/images/

      {image}

      ")
      @Consumes
      @Produces("/")
      public Response findImage(@PathParam("image") String image) {
      ...
      final File file = new File(BASE_PATH + image);
      if (!file.exists())

      { return Response.status(NOT_FOUND) .type(TEXT_PLAIN) .entity("... error message ...") .build(); }

      String contentType = new MimetypesFileTypeMap().getContentType(file);
      return Response.ok(file, contentType).build();

      }

      Stacktrace:
      ERROR core.SynchronousDispatcher - Failed executing GET /kundenverwaltung/images/java.gif
      org.jboss.resteasy.spi.LoggableFailure: Could not find MessageBodyWriter for response object of type: java.io.File of media type: image/gif
      at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:418)
      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:370)
      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:189)
      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:82)
      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:66)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at de.hska.util.HskaFilter.doFilter(HskaFilter.java:46)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
      at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:857)
      at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565)
      at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
      at java.lang.Thread.run(Thread.java:619)

      Changing @Produces("/") to @Produces("image/gif") yields the same stacktrace.

      Changing the method's return type to File and returning the file object yields the string of the absolute file name.

      BTW, both variants are working with Jersey.

              patriot1burke@gmail.com Bill Burke (Inactive)
              juergen.zimmermann Juergen Zimmermann (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: