users@jersey.java.net

[Jersey] Testing with JBoss RestEasy - Unable to find a MessageBodyReader

From: Sohail <sohail_at_tribaltech.com>
Date: Tue, 7 Dec 2010 13:39:22 -0800 (PST)

I'm getting the following error when running a simple junit test using the
Jboss resteasy client. I'm making a get request to the service and getting
a response but am unable to marshall the response which is a list of
objects. Here is the code:

        @Test
        public void testGetChallenges() throws Exception {
                log.info("testGetChallenges");
                ResteasyProviderFactory factory = new ResteasyProviderFactory();

                UriBuilder builder = new UriBuilderImpl().uriTemplate("[URL HERE]");
                ClientRequest request = new ClientRequest(builder, new
ApacheHttpClientExecutor(), factory);
                request.accept(MediaType.APPLICATION_XML);


                log.info("Making call to getChallenges");
                ClientResponse response = request.get();
                log.info("Response status for getChallenges: " + response.getStatus());

                if (response.getStatus() == 200) {
                        List<Challenge> challenges = (List<Challenge>) response.getEntity(new
GenericType<ArrayList<Challenge>>() {
                        });
                }
        }

And here is the error:

Unable to find a MessageBodyReader of content-type application/xml and type
java.util.ArrayList<tribal.pojo.ws.pointsandrewards.Challenge>
org.jboss.resteasy.client.ClientResponseFailure: Unable to find a
MessageBodyReader of content-type application/xml and type
java.util.ArrayList<tribal.pojo.ws.pointsandrewards.Challenge>
        at
org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:351)
        at
org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:342)
        at
org.jboss.resteasy.client.core.BaseClientResponse$1.createReaderNotFound(BaseClientResponse.java:286)
        at
org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:106)
        at
org.jboss.resteasy.client.core.BaseClientResponse.readFrom(BaseClientResponse.java:291)
        at
org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:255)
        at
org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:228)
        at
org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:305)
        at
tribal.ws.pointsandrewards.ChallengesResourceTest.testGetChallenges(ChallengesResourceTest.java:61)
-- 
View this message in context: http://jersey.576304.n2.nabble.com/Testing-with-JBoss-RestEasy-Unable-to-find-a-MessageBodyReader-tp5813344p5813344.html
Sent from the Jersey mailing list archive at Nabble.com.