开发者

unable to find a MessageBodyReader

I have this interface:

 @Path("inbox")
public interface InboxQueryResourceTest {

    @POST
    @Path("{membershipExternalId}/query")
    @Consumes(MediaType.APPLICATION_XML)
    @Produces("multipart/mixed")
    public MultipartOutput query(@PathParam("membershipExternalId") final String membershipExternalId,
                             @QueryParam("page") @DefaultValue("0") final int page,
                             @QueryParam("pageSize") @DefaultValue("10") final int pageSize,
                             @QueryParam("sortProperty") final List<String> sortPropertyList,
                             @QueryParam("so开发者_开发知识库rtReversed") final List<Boolean> sortReversed,
                             @QueryParam("sortType") final List<String> sortTypeString,
                             final InstanceQuery instanceQuery) throws IOException;
}

I have implemented the method to return a MultipartOutput. I am posting an xml query from Fiddler and i receive the result without any problem.

BUT i have done an integration test for the same interface, i send the same objects and i put the response like:

final MultipartOutput multiPartOutput = getClient().query(getUserRestAuth(), 0, 25, null, null, null, instanceQuery);

But here, so from integration tests, i receive a strange error:

Unable to find a MessageBodyReader of content-type multipart/mixed;boundary="74c5b6b4-e820-452d-abea-4c56ffb514bb" and type class org.jboss.resteasy.plugins.providers.multipart.MultipartOutput

Anyone has any ideea why only in integration tests i receive this error?

PS: Some of you will say that i do not send application/xml as ContentType but multipart, which of course is false because the objects are annotated with the required @XmlRootElement etc, otherways neither the POST from Fiddler would work.


You can try this:

ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
providerFactory.registerProvider(org.jboss.resteasy.plugins.providers.multipart.MimeMultipartProvider.class);


Are including in classpath the corresponding resteasy addon for multipart encoding? (esteasy-multipart-provider).


Try adding this method to your test class. This would register the default built-in providers which are already registered on your server.

@BeforeClass
public static void registerProviders() {
    ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
    RegisterBuiltin.register(providerFactory);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜