title: JAX-RS - Could not find MessageBodyWriter for response object of type
body: <p>I am trying to work out a sample of JAX-RS in JBoss 7.2 Rest Easy. I am getting a Error message as below. </p>
  
  <blockquote>
    <p>SEVERE [org.jboss.resteasy.core.SynchronousDispatcher]
    (http-/0.0.0.0:80-2) Failed executing GET /test/resources/1:
    org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not
    find MessageBodyWriter for response object of type: vsample.Image of
    media type: image/jpeg    at
    org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:216)
    [resteasy-jaxrs-2.3.5.Final.jar:]     at
    org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:602)
    [resteasy-jaxrs-2.3.5.Final.jar:]     at
    org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:528)
    [resteasy-jaxrs-2.3.5.Final.jar:]     at
    org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
    [resteasy-jaxrs-2.3.5.Final.jar:]     at
    org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
    [resteasy-jaxrs-2.3.5.Final.jar:]     at
    org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
    [resteasy-jaxrs-2.3.5.Final.jar:]     at
    org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
    [resteasy-jaxrs-2.3.5.Final.jar:]     at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    [jboss-servlet-api_3.0_spec-1.0.2.Final.jar:1.0.2.Final]  at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
    [jboss-as-web-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)
    [jbossweb-7.2.0.Final.jar:7.2.0.Final]    at
    java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]</p>
  </blockquote>
  
  <p>And my code is,</p>
  
  <pre><code> import javax.ws.rs.ApplicationPath;
       import javax.ws.rs.Produces;
       import javax.ws.rs.core.Application;
  
  
       @ApplicationPath("/rest")
     public class Etag extends Application {
      }
  </code></pre>
  
  <p>And,</p>
  
  <pre><code>import java.util.Date;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  import javax.ws.rs.PathParam;
  import javax.ws.rs.core.Context;
  import javax.ws.rs.core.Request;
  import javax.ws.rs.core.CacheControl;
  import javax.ws.rs.core.EntityTag;
  import javax.ws.rs.core.Response.ResponseBuilder;
  
  
  @Path( "/test" )
  public class EtagImpl {
  
     @GET
     @Produces("image/jpeg")
  
     @Path("resources/{id}")
        public Response getImage(@PathParam("id") String id, @Context Request request) {
  
         ImageDAOImpl imageDAO = new ImageDAOImpl();
  
          Image image = imageDAO.getImage(id);
         CacheControl cc = new CacheControl();
         cc.setMaxAge(172800); // 2 days
         Response.ResponseBuilder rb = null;
         String lastModified = image.getDateModified().toString();
       //  EntityTag etag = new EntityTag(imageDAO.getImage(id).hashCode()+"");
         EntityTag etag = new EntityTag(lastModified.hashCode()+"");
         System.out.println("Writing Response:" + etag);
         rb = request.evaluatePreconditions(etag);
         if (rb != null) 
         {
             return rb.cacheControl(cc).tag(etag).build();
         }
  
         //If rb is null then either it is first time request; or resource is modified
         //Get the updated representation and return with Etag attached to it
                 rb = Response.ok(imageDAO.getImage(id)).cacheControl(cc).tag(etag);
                 return rb.build();
      } 
  </code></pre>
  
  <p>As I am new to RestEasy, it will be helpful to get ideas to proceed in right direction</p>
  
  <p>Thanks and Regards,
  Ram.</p>