org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: java.lang.String of media type: application/json

JBoss Issue Tracker | Mark S | 5 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I think the following describes a bug as I expect a Resteasy service to handle a java.lang.String return type successfully. I am using Resteasy in a ServiceMix 4.4.0 deployment. The Rest service is exposed via OSGi and consumed by another OSGi bundle. I have attached the sample project source code. ******************** The following two method signatures when called via a Resteasy client will through an exception. See helloworld-integration-test/src/test/java/test/api/svc/HelloSvcTest.java ******************** * The method signatures that throw an exception: {code} @POST @Path( "/StandardGreeting" ) @Consumes( { "application/json", "text/json" } ) @Produces( { "application/json", "text/json" } ) @GZIP @Override public Response getStandardGreeting( GreetingRequest request ) { String value = "Hi " + request.getRecipientName() + "..." + " " + "How is it going?"; return Response.ok().entity( new String( value ) ).build(); } {code} {code} @POST @Path( "/SimpleHelloGreeting" ) @Consumes( { "application/json", "text/json" } ) @Produces( { "application/json", "text/json" } ) @GZIP @Override public String getSimpleHelloGreeting( GreetingRequest request ) { String value = "Hello " + request.getRecipientName() + "!!!"; return new String( value ); } {code} * Will throw the following exception: {code} 17:51:20,783 | ERROR | qtp628451228-74 | SynchronousDispatcher | 651 - helloworld-org-jboss-resteasy - 2.2.3.GA | Failed executing POST /service/StandardGreeting org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: java.lang.String of media type: application/json at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:216)[651:helloworld-org-jboss-resteasy:2.2.3.GA] at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:579)[651:helloworld-org-jboss-resteasy:2.2.3.GA] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:500)[651:helloworld-org-jboss-resteasy:2.2.3.GA] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)[651:helloworld-org-jboss-resteasy:2.2.3.GA] at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)[651:helloworld-org-jboss-resteasy:2.2.3.GA] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)[651:helloworld-org-jboss-resteasy:2.2.3.GA] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)[651:helloworld-org-jboss-resteasy:2.2.3.GA] at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)[111:org.apache.geronimo.specs.geronimo-servlet_2.5_spec:1.1.2] at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538)[99:org.eclipse.jetty.servlet:7.4.5.v20110725] at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:478)[99:org.eclipse.jetty.servlet:7.4.5.v20110725] at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[113:org.ops4j.pax.web.pax-web-jetty:1.0.7] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:480)[101:org.eclipse.jetty.security:7.4.5.v20110725] at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:937)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:116)[113:org.ops4j.pax.web.pax-web-jetty:1.0.7] at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)[99:org.eclipse.jetty.servlet:7.4.5.v20110725] at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:871)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:72)[113:org.ops4j.pax.web.pax-web-jetty:1.0.7] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.server.Server.handle(Server.java:346)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:589)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1065)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823)[102:org.eclipse.jetty.http:7.4.5.v20110725] at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)[102:org.eclipse.jetty.http:7.4.5.v20110725] at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:411)[98:org.eclipse.jetty.server:7.4.5.v20110725] at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535)[100:org.eclipse.jetty.io:7.4.5.v20110725] at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)[100:org.eclipse.jetty.io:7.4.5.v20110725] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)[110:org.eclipse.jetty.util:7.4.5.v20110725] at java.lang.Thread.run(Thread.java:662)[:1.6.0_27] {code} * The JUnit tests that fail (helloworld-integration-test\src\test\java\test\api\svc\HelloSvcTest.java): {code} @SuppressWarnings( "static-method" ) @Test public void testGetStandardGreeting() { ClientRequest request = null; ClientResponse<String> response = null; try { GreetingRequest greetingRequest = new GreetingRequest(); greetingRequest.setRecipientName( "World" ); // // Make the Service Call // request = new ClientRequest( "http://localhost:8181/service/StandardGreeting" ); request.accept( MediaType.APPLICATION_JSON ); request.body( MediaType.APPLICATION_JSON, greetingRequest ); response = request.post( String.class ); // // Handle the Service Response // Assert.assertEquals( Response.Status.OK.getStatusCode(), response.getStatus() ); Assert.assertEquals( "Hi World... How is it going?", response.getEntity() ); } catch ( Exception e ) { throw new RuntimeException( e ); } finally { if ( null != response ) { response.releaseConnection(); } } } @SuppressWarnings( "static-method" ) @Test public void testGetSimpleHelloGreeting() { ClientRequest request = null; ClientResponse<String> response = null; try { GreetingRequest greetingRequest = new GreetingRequest(); greetingRequest.setRecipientName( "World" ); // // Make the Service Call // request = new ClientRequest( "http://localhost:8181/service/SimpleHelloGreeting" ); request.accept( MediaType.APPLICATION_JSON ); request.body( MediaType.APPLICATION_JSON, greetingRequest ); response = request.post( String.class ); // // Handle the Service Response // Assert.assertEquals( Response.Status.OK.getStatusCode(), response.getStatus() ); Assert.assertEquals( "Hello World!!!", response.getEntity() ); } catch ( Exception e ) { throw new RuntimeException( e ); } finally { if ( null != response ) { response.releaseConnection(); } } } {code}

    JBoss Issue Tracker | 5 years ago | Mark S
    org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: java.lang.String of media type: application/json
  2. 0

    NoMessageBodyWriterFoundFailure resteasy

    Stack Overflow | 2 years ago | Ramesh
    org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: UserInfo of media type: application/json
  3. 0

    Post request from Android application failing + RestEasy + Jackson - Android - Android Puzzles(Questions & Answers)

    phonesdevelopers.com | 2 years ago
    org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: domains.Post of media type: application/octet-stream
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Post request from Android application failing + RestEasy + Jackson

    Stack Overflow | 3 years ago | Ilhami
    org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: domains.Post of media type: application/octet-stream
  6. 0

    jersey sse doesn't work on wildfly 8.2

    Stack Overflow | 2 years ago
    org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: org.glassfish.jersey.media.sse.EventOutput of media type: text/event-stream

    17 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure

      Could not find MessageBodyWriter for response object of type: java.lang.String of media type: application/json

      at org.jboss.resteasy.core.ServerResponse.writeTo()
    2. RESTEasy JAX-RS Implementation
      HttpServletDispatcher.service
      1. org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:216)[651:helloworld-org-jboss-resteasy:2.2.3.GA]
      2. org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:579)[651:helloworld-org-jboss-resteasy:2.2.3.GA]
      3. org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:500)[651:helloworld-org-jboss-resteasy:2.2.3.GA]
      4. org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)[651:helloworld-org-jboss-resteasy:2.2.3.GA]
      5. org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)[651:helloworld-org-jboss-resteasy:2.2.3.GA]
      6. org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)[651:helloworld-org-jboss-resteasy:2.2.3.GA]
      7. org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)[651:helloworld-org-jboss-resteasy:2.2.3.GA]
      7 frames
    3. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:806)[111:org.apache.geronimo.specs.geronimo-servlet_2.5_spec:1.1.2]
      1 frame
    4. Jetty
      ServletHandler.doHandle
      1. org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538)[99:org.eclipse.jetty.servlet:7.4.5.v20110725]
      2. org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:478)[99:org.eclipse.jetty.servlet:7.4.5.v20110725]
      2 frames
    5. OPS4J Pax Web - Jetty
      HttpServiceServletHandler.doHandle
      1. org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[113:org.ops4j.pax.web.pax-web-jetty:1.0.7]
      1 frame
    6. Jetty
      ContextHandler.doHandle
      1. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      2. org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:480)[101:org.eclipse.jetty.security:7.4.5.v20110725]
      3. org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      4. org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:937)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      4 frames
    7. OPS4J Pax Web - Jetty
      HttpServiceContext.doHandle
      1. org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:116)[113:org.ops4j.pax.web.pax-web-jetty:1.0.7]
      1 frame
    8. Jetty
      ScopedHandler.handle
      1. org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)[99:org.eclipse.jetty.servlet:7.4.5.v20110725]
      2. org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      3. org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:871)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      4. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      4 frames
    9. OPS4J Pax Web - Jetty
      JettyServerHandlerCollection.handle
      1. org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:72)[113:org.ops4j.pax.web.pax-web-jetty:1.0.7]
      1 frame
    10. Jetty
      HttpConnection.handle
      1. org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      2. org.eclipse.jetty.server.Server.handle(Server.java:346)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      3. org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:589)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      4. org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1065)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      5. org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823)[102:org.eclipse.jetty.http:7.4.5.v20110725]
      6. org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)[102:org.eclipse.jetty.http:7.4.5.v20110725]
      7. org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:411)[98:org.eclipse.jetty.server:7.4.5.v20110725]
      7 frames
    11. GWT dev
      SelectChannelEndPoint$1.run
      1. org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535)[100:org.eclipse.jetty.io:7.4.5.v20110725]
      2. org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)[100:org.eclipse.jetty.io:7.4.5.v20110725]
      2 frames
    12. Jetty
      QueuedThreadPool$3.run
      1. org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)[110:org.eclipse.jetty.util:7.4.5.v20110725]
      1 frame
    13. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:662)[:1.6.0_27]
      1 frame