users@jersey.java.net

[Jersey] Re: Twitter4j & Jersey: WebApplicationException

From: Martin Matula <martin.matula_at_oracle.com>
Date: Wed, 09 Mar 2011 01:57:51 +0100

The client does not seem to expect JSON, which is the reason of the
first issue.
Regarding the second issue - have you turned on the POJO mapping
feature?
(http://jersey.java.net/nonav/documentation/latest/json.html#d4e878)
What version of Jersey are you using?
Martin

On 8.3.2011 17:21, mahan_h wrote:
> I tried both
> @Produces("application/json")
> and
> @Produces(MediaType.APPLICATION_JSON)
>
> gives me the following error:
>
> HTTP Status 406 -
> type Status report
> message
>
> description The resource identified by this request is only capable of
> generating responses with characteristics not acceptable according to the
> request "accept" headers ().
>
> A message body writer for Java type, class twitter4j.TweetJSONImpl, and MIME
> media type, application/json, was not found
>
> service impl:
> @Produces(MediaType.APPLICATION_JSON)
> @GET
> @Path("{phrase}")
> public Tweet searchPhrase(@PathParam("phrase") String keyword) {
> Twitter twitter = new TwitterFactory().getInstance();
> List tweets = new ArrayList();
> ...
> get the tweets...
> ...
> return tweets.get(0);
> }
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Twitter4j-Jersey-WebApplicationException-tp6095973p6129105.html
> Sent from the Jersey mailing list archive at Nabble.com.