On Thu, Apr 14, 2011 at 4:55 AM, sudhakar <sudhakar.dunaka_at_tcs.com> wrote:
> Hi,
>
> i am trying to post a JSonObject to REST Service,but i am not able to do
> this.while i am running my client program i am getting following exception
>
> com.sun.jersey.api.client.ClientHandlerException: A message body reader for
> Java class net.sf.json.JSONObject, and Java type class
> net.sf.json.JSONObject, and MIME media type, application/json, was not found
The reason is that neither Jersey nor Jackson directly supports
JSONObject, which is abstraction provided by some other library (json
tools or json util, forget which one).
So if you absolutely have/want to use it, you need to add bindings via
MessageBodyReader/Writer; or declare type as byte[] and handle data
binding yourself.
Latter is quite easy, so I'd probably go with that.
But I suspect you might just want to provide real Java POJOs and not
use library-specific models. There is often no need to use such things
-- that's one of big advantages of JAX-RS over more manual way of
doing things.
-+ Tatu +-