I'm using the Jersey Client to call a web service which returns JSON.
Here's an example response:
INFO: 1 * Client in-bound response
1 < 200
1 < X-AspNet-Version: 4.0.30319
1 < Records: 1
1 < Date: Mon, 05 Nov 2012 14:51:21 GMT
1 < Content-Length: 91
1 < Expires: -1
1 < Content-Type: text/html
1 < X-Powered-By: ASP.NET
1 < Server: Microsoft-IIS/7.5
1 < Pragma: no-cache
1 < Cache-Control: no-cache
1 <
[{"Id":"13676325.00","StreetAddress":"103 Stad Ty
Croes","Place":"Llanfairpwllgwyngyll"}]
The MIME type seems to be incorrect for JSON but I can read this with:
ClientConfig clientConfig = new DefaultClientConfig();
Client c = Client.create(clientConfig);
WebResource r = c.resource(<serviceUrl>);
String response = r.queryParams(params)
.accept(MediaType.TEXT_HTML)
.get(String.class);
This works fine on one (Mac OS X) machine but on a separate machine
running OpenJDK7 the same project fails with the following exception:
Nov 05, 2012 2:50:08 PM com.sun.jersey.api.client.ClientResponse
getEntity
SEVERE: A message body reader for Java class java.lang.String, and Java
type class java.lang.String, and MIME media type text/html was not
found
Nov 05, 2012 2:50:08 PM com.sun.jersey.api.client.ClientResponse
getEntity
SEVERE: The registered message body readers compatible with the MIME
media type are:
*/* ->
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$Genera
l
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Genera
l
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$Genera
l
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
Any ideas why this is working on one jvm and not another?