org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException:找不到媒体类型= text / plain的MessageBodyReader;字符集= ISO-8859-1

时间:2015-11-20 06:34:41

标签: rest rest-assured

我正在尝试使用restassured framework调用rest服务 - 获得此异常。

  

org.glassfish.jersey.server.ServerRuntime $ Responder mapException      警告:WebApplicationException导致:   org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException:找不到媒体类型= text / plain的MessageBodyReader; charset = ISO-8859-1,type = class com.digicel.selfcare.service.services.beans.request.FacebookNewsFeedRequest,genericType = class com.digicel.selfcare.service.services.beans.request.FacebookNewsFeedRequest。       at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor $ TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:207)       at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:139)       at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:72)       at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:139)       在org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1109)       at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:851)       在org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:253)       at org.glassfish.jersey.server.internal.inject.EntityParamValueFactoryProvider $ EntityValueFactory.provide(EntityParamValueFactoryProvider.java:96)       在org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:81)       at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider $ AbstractMethodParamInv

@Path("social/")
public class MyService{

@POST
@Path("facebook/feeds")
@Produces(MediaType.APPLICATION_JSON)
public List<FacebookNewsFeedResult>getFacebookNewsFeed(FacebookNewsFeedRequest request, @Context HttpServletRequest httpReq)
}

这是我的jUnit:使用restassured

 @Test
 public void getFacebookNewsFeedTest() throws Exception
 {
  final String resource = "social/facebook/feeds";

  String jsonContent = "{\"feedId\": \"100\",\"pull\": \"true\"}";

  expect().spec(okResponse).with().headers(this.authorizedHeaders).content(ContentType.JSON).content(jsonContent).post(selfCareServiceTest.buildURLForResource(resource));
  }

0 个答案:

没有答案