Quantcast

Jersey Client, POST JSONObject issue.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Jersey Client, POST JSONObject issue.

Scott Glass-2
I'm trying to POST a JSONObject using the Jersey Client to a URL and am getting the following message from the service....

com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class org.codehaus.jettison.json.JSONObject, and MIME media type, application/json, was not found

This is with Jersey 1.3 and the class loader hack in place.

Any ideas, I searched the documentation online found this, but it's throwing an exception...

config.getClasses().add(JSONRootElementProvider.class);

http://blogs.sun.com/enterprisetechtips/entry/consuming_restful_web_services_with

Thanks,
Scott


--
Scott Glass
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jersey Client, POST JSONObject issue.

Paul Sandoz
Administrator
Hi Scott,

If you include the Jersey JSON module in the class path there should be no need for any explicit registration.

The class you registered, JSONRootElementProvider, is for JAXB, the relevant component for JSONObject is com.sun.jersey.json.impl.provider.entity.JSONObjectProvider. I think there is an error in the tech tip, it should not be even mentioning that, so the example is very misleading.

When you say "the class loader hack in place" what hack are you referring to?

Paul.

On Jun 28, 2010, at 9:04 PM, Scott Glass wrote:

I'm trying to POST a JSONObject using the Jersey Client to a URL and am getting the following message from the service....

com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class org.codehaus.jettison.json.JSONObject, and MIME media type, application/json, was not found

This is with Jersey 1.3 and the class loader hack in place.

Any ideas, I searched the documentation online found this, but it's throwing an exception...

config.getClasses().add(JSONRootElementProvider.class);

http://blogs.sun.com/enterprisetechtips/entry/consuming_restful_web_services_with

Thanks,
Scott


--
Scott Glass

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jersey Client, POST JSONObject issue.

Scott Glass-2

Hi Paul,
Remember a couple weeks back we had to do that classloader switch to get Jersey to see its required classes.  I'll start with upgrading to 1.3 and see if it fixes it.

Thanks,
Scott

On Jun 29, 2010 5:16 AM, "Paul Sandoz" <[hidden email]> wrote:

Hi Scott,

If you include the Jersey JSON module in the class path there should be no need for any explicit registration.

The class you registered, JSONRootElementProvider, is for JAXB, the relevant component for JSONObject is com.sun.jersey.json.impl.provider.entity.JSONObjectProvider. I think there is an error in the tech tip, it should not be even mentioning that, so the example is very misleading.

When you say "the class loader hack in place" what hack are you referring to?

Paul.



On Jun 28, 2010, at 9:04 PM, Scott Glass wrote:

> I'm trying to POST a JSONObject using the Jerse...

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jersey Client, POST JSONObject issue.

Paul Sandoz
Administrator

On Jun 29, 2010, at 1:55 PM, Scott Glass wrote:

Hi Paul,
Remember a couple weeks back we had to do that classloader switch to get Jersey to see its required classes.


I recall now, using the thread context class loader. That trick should also work if the Jersey JSON jar is in the class path along with it's associated dependencies.

Paul.

  I'll start with upgrading to 1.3 and see if it fixes it.

Thanks,
Scott


On Jun 29, 2010 5:16 AM, "Paul Sandoz" <[hidden email]> wrote:

Hi Scott,

If you include the Jersey JSON module in the class path there should be no need for any explicit registration.

The class you registered, JSONRootElementProvider, is for JAXB, the relevant component for JSONObject is com.sun.jersey.json.impl.provider.entity.JSONObjectProvider. I think there is an error in the tech tip, it should not be even mentioning that, so the example is very misleading.

When you say "the class loader hack in place" what hack are you referring to?

Paul.



On Jun 28, 2010, at 9:04 PM, Scott Glass wrote:

> I'm trying to POST a JSONObject using the Jerse...



Loading...