users@jersey.java.net

[Jersey] jersey-proxy-client with 1.x and generic collection return types

From: Guy Rouillier <guy.rouillier_at_gmail.com>
Date: Wed, 11 Jul 2012 01:52:42 -0400

I like the concept the Jersey proxy client; it enables much more natural
usage of web services on the client side. We are using Jersey 1.x since
2.0 is still in development. I see the the proxy client module has the
revision tag for version 1.13 (revision 5739) so I checked that out and
built it. It somewhat works following the supplied example for simple
return types (single instance classes, not collections.) I say somewhat
because I couldn't get it to build properly if I just had the
annotations on the interface; I had to repeat the same annotations on
the resource class, or Jersey wouldn't create the resource at run time.

However, I've been struggling (unsuccessfully) for two days now trying
to get methods working that return generic collections. For example,
with the following web service method:

      @GET
      @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
      @Path("listByProspectiveCustomer")
      public List<Contact>
getProspectiveContactListByCustomer(@QueryParam("id") String customerId);

The invocation gets to the server, and the server returns the result to
the client. But then the client gets this error:

Jul 10, 2012 11:21:26 PM com.sun.jersey.api.client.ClientResponse getEntity
SEVERE: A message body reader for Java class java.util.List, and Java
type interface java.util.List, and MIME media type application/xml was
not found
Jul 10, 2012 11:21:26 PM com.sun.jersey.api.client.ClientResponse getEntity
SEVERE: The registered message body readers compatible with the MIME
media type are:
application/xml ->
....

The list is pretty long so I'll leave it off. The example shows:

     @GET
     @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     List<Book> getBooks();

which is pretty much exactly what I have. So does the proxy client just
not work with 1.x? If it should, how do I fix this?

Thanks.

-- 
Guy Rouillier