org.jboss.resteasy.resteasy_jaxrs.i18n; org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure报错

本文记录了在Resteasy和SpringBoot集成过程中遇到的REST接口请求错误,并详细描述了解决方案。问题在于未指定返回体类型,通过添加@Produces注解指定了返回媒体类型为JSON,成功解决了接口返回的问题。

resteasy和springboot集成暴露rest接口请求报错

2020-02-24 10:45:55.358 ERROR 11032 --- [-BIZ-8341-10-T1] org.jboss.resteasy.resteasy_jaxrs.i18n   : RESTEASY002005: Failed executing GET /get/students

org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: text/html;charset=UTF-8
	at org.jboss.resteasy.core.ServerResponseWriter.lambda$writeNomapResponse$2(ServerResponseWriter.java:105) ~[resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.interception.ContainerResponseContextImpl.filter(ContainerResponseContextImpl.java:398) ~[resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.ServerResponseWriter.executeFilters(ServerResponseWriter.java:206) ~[resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:82) ~[resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:56) ~[resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:528) [resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:459) [resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at com.alipay.sofa.rpc.server.rest.SofaSynchronousDispatcher.invoke(SofaSynchronousDispatcher.java:49) [sofa-rpc-all-5.6.4.jar:5.6.4]
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229) [resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135) [resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:355) ~[resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138) [resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215) [resteasy-jaxrs-3.6.3.Final.jar:3.6.3.Final]
	at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83) ~[resteasy-netty4-3.6.3.Final.jar:3.6.3.Final]
	at com.alipay.sofa.rpc.server.rest.SofaRestRequestHandler.channelRead0(SofaRestRequestHandler.java:102) ~[sofa-rpc-all-5.6.4.jar:5.6.4]
	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:56) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-all-4.1.43.Final.jar:4.1.43.Final]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_231]

接口定义如下:

@Path("get")
public interface StudentApi {

    @GET
    @Path("students")
    List<StudentDetailDto> getStudentList();
}

经过排查,是由于没有指定返回体类型导致的,新增注解指定返回媒体类型,接口顺利返回

@Path("get")
@Produces({MediaType.APPLICATION_JSON})
public interface StudentApi {

    @GET
    @Path("students")
    List<StudentDetailDto> getStudentList();
}
2025-05-27 17:29:45.743 ERROR 15325 --- [nio-8810-exec-4] [] [] org.jboss.resteasy.resteasy_jaxrs.i18n : RESTEASY002010: Failed to execute javax.ws.rs.NotSupportedException: RESTEASY003200: Could not find message body reader for type: class com.spotter.dtg.aetherflow.admin.adapter.web.request.liteChain.LiteUpdateFlowReq of content type: text/plain;charset=UTF-8 at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.throwReaderNotFound(ServerReaderInterceptorContext.java:53) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:80) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:198) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:91) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:113) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:543) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:432) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:393) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:395) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:364) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440) [resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229) [resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135) [resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138) [resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215) [resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) ~[resteasy-jaxrs-3.12.1.Final.jar:3.12.1.Final]
05-28
异常 : javax.ws.rs.NotSupportedException: RESTEASY003200: Could not find message body reader for type: class com.spotter.dtg.aetherflow.admin.adapter.web.request.LiteSearchFlowReq of content type: */* at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.throwReaderNotFound(ServerReaderInterceptorContext.java:53) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:80) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53) at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:198) at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:91) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:113) at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:543) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:432) at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:393) at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:395) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:364) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440) at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229) at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135) at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358) at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) at org.apache.dubbo.rpc.protocol.rest.DubboHttpProtocolServer$RestHandler.handle(DubboHttpProtocolServer.java:89) at org.apache.dubbo.remoting.http.servlet.DispatcherServlet.service(DispatcherServlet.java:61) 的解决方案
03-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值