users@jersey.java.net

[Jersey] Re: Twitter4j & Jersey: WebApplicationException

From: Petr Jurák <petr.jurak_at_gmail.com>
Date: Tue, 8 Mar 2011 18:33:45 +0100

Removing XML annotation isn't necessary in my opinion. But you should check
what your client sends to resource (server), mainly look at Accept http
header. It should include * or application/json.
Regards,
Petr

-----Original Message-----
From: mahan_h [mailto:mahorad_at_gmail.com]
Sent: Tuesday, March 08, 2011 5:21 PM
To: users_at_jersey.java.net
Subject: [Jersey] Re: Twitter4j & Jersey: WebApplicationException

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.