Could not find MessageBodyWriter for type response object

I am getting the following error when trying to access a method in a web service. I have set JSON as the response type. The request is sent to the webservice. But I cannot get an answer.

SEVERE: Servlet.service() for servlet [resteasy-servlet] in context with path [/core-ws] threw exception
org.jboss.resteasy.spi.UnhandledException: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: com.fg.banking.model.rest.response.ServerErrorResponse of media type: application/octet-stream
    at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:157)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:176)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: com.fg.banking.model.rest.response.ServerErrorResponse of media type: application/octet-stream
    at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:67)
    at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:153)
    ... 24 more

      

My client code

@Override public list getAllFunctions () {

Response response = null;
try {

    response = super.get(this.targetServiceUrl + WSPath.GET_ALL_FUNCTIONS);
    List<Function> functions  =
            response.readEntity(new GenericType<List<Function>>() {});
    return functions;
} catch (Exception e) {

    throw new InternalServerErrorException(e);
} finally {

    response.close();
}

      

}

My web service code

@Component
@Produces(MediaType.APPLICATION_JSON)
@Path(WSPath.MISCELLANEOUS_SERVICE)
public class MiscellaneousResource {

    @Autowired
    private MiscellaneousService miscellaneousService;

    @Autowired
    private InstrumentService instrumentService;
    @GET
    @Path(WSPath.GET_ALL_FUNCTIONS)
    public Response getAllFunctions() {

        List<Function> functions = miscellaneousService.getAllFunctions();
        return Response.ok(functions).build();
    }
}

      

Please help me to overcome this exception

+3


source to share





All Articles