找不到类型的响应对象的MessageBodyWriter

时间:2014-08-12 12:42:20

标签: java web-services jboss response media-type

当我尝试访问Web服务中的方法时,我收到以下错误。我已将JSON设置为响应类型。请求将发送到Web服务。但我无法得到答复。

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

我的客户代码

@覆盖 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();
}

}

我的网络服务代码

@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();
    }
}

请帮我克服这个异常

0 个答案:

没有答案