Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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("sortReversed") 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.

like image 646
Cristian Boariu Avatar asked Mar 11 '10 13:03

Cristian Boariu


1 Answers

You can try this:

ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
providerFactory.registerProvider(org.jboss.resteasy.plugins.providers.multipart.MimeMultipartProvider.class);
like image 139
Nikita Koksharov Avatar answered Oct 21 '22 08:10

Nikita Koksharov