Hi Colin,
The JSON processing will automatically work
only for JAXB beans. I guess it is not the case
of your SearchResults class.
To fix this, you will need to set
the JSONConfiguration.FEATURE_POJO_MAPPING
feature on your client config, e.g.
ClientConfig cc = new DefaultClientConfig();
cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
Client c = Client.create(cc);
...
You will need to have jackson libs on the classpath,
which you will get automatically if you use maven.
Otherwise please see [1] for the links to the 3 jackson jars
you need to use.
HTH,
~Jakub
[1]
http://jersey.java.net/nonav/documentation/latest/chapter_deps.html#d4e1696
On 03/18/2011 10:18 AM, Colin Vipurs wrote:
> Hi all,
>
> This feels like a stupid thing to ask, but I haven't found an answer
> yet. I have a service for which I expose a client JAR containing all
> classes that are marshalled through my exposed Json endpoint. I
> thought (and fairly sure that I'd tested) that all someone needed was
> the jersey-client dependency and they could automagically convert the
> json response into an object hierarchy.
>
> What I thought we could do is....
>
> SearchResults results =
> client.resource(UriBuilder.fromPath("http://searchhost/search")
> .path(SearchType.WEB.toString().toLowerCase())
> .path(SearchDomain.ALL.toString())
> .path("tigertailz").build()).get(SearchResults.class);
>
> But we get the error.,.
>
> Exception in thread "main"
> com.sun.jersey.api.client.ClientHandlerException: A message body
> reader for Java class SearchResults, and Java type class
> SearchResults, and MIME media type application/json was not found.
>
> The dev working on this says he's followed all kinds of tutorials and
> nothing works. This seems like we're missing something very simple -
> can someone put us on the right path?
>
>
>
--
Jakub Podlešák
CZJUG co-lead,
Web Services Research And Development
Oracle, Czech s r.o.
Praha 4, V Parku 8