users@jersey.java.net

[Jersey] Re: jersey-client 2.14

From: Mikael Ståldal <mikael.staldal_at_appearnetworks.com>
Date: Wed, 17 Dec 2014 15:08:20 +0100

You need to tell Jersey client that it is a collection of Idm you want,
which is a bit tricky due to Java's generic erasure.

Try this:

Idm[] result = clientResponse.getEntity(Idm[].class);

On Wed, Dec 17, 2014 at 2:53 PM, Tomaz Majerhold <tomaz.majerhold_at_arnes.si>
wrote:
>
> How the client read Collection<Idm>()
>
> 1) On server side:
> @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
> public Collection<Idm> serachIdms
>
> and server side generate XML I can see it in TCP/IP monitor
>
>
> 2) On the client side I have problem
>
> clientResponse = webResource
> .path(path)
> .queryParam("url", url)
> .queryParam("description", description)
> .accept(MediaType.APPLICATION_XML)
> .get(ClientResponse.class);
>
> result = (Collection<Idm>) clientResponse.getEntity(Collection.class);
>
>
> Exception:
> com.sun.jersey.api.client.ClientHandlerException: A message body reader
> for Java class java.util.Collection, and Java type interface
> java.util.Collection, and MIME media type application/xml was not found
> at com.sun.jersey.api.client.ClientResponse.getEntity(
> ClientResponse.java:561)
> at com.sun.jersey.api.client.ClientResponse.getEntity(
> ClientResponse.java:517)
>
>
> Any idea what is wrong?
>
> Regards, Tomaz
>


-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.staldal_at_appearnetworks.com