users@jersey.java.net

[Jersey] Jersey client doesnt seem to parse json response as well as xml

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Fri, 2 Mar 2012 00:52:33 -0800 (PST)

Hi all,

I came across an issue with using Jersey client. I can't seem to find anything related to this, maybe it's just our code. We're using the jersey client on a consumer app that calls our rest api. We share a set of representations between the two tiers, so the code to serialize/deserialize I would assume is the same on both the client and server. When I make a call setting the Accept header to application/json using the swing rest client or Eclipse Http4e, the response is json. If I set Accept to xml, it comes back as xml. That's all good. But when I use jersey client to send a request, specifying the type as json, results in an internal NPE, but changing it to XML the response is properly converted back into the object. It seems to be an issue with jersey client deseralizing the json the server sends converting it back into the same object that the server sent. I don't recall having this problem before, and I recently upgraded to jersey 1.12. I don't have
 my code up in front of me to provide an example, I am hoping it's a known issue and/or work around and someone can enlighten me. Incidentally, we're using the same jersey client code to send the same object to another server in json format and it works. One thing I haven't checked yet is if one server is 1.11 and one is 1.12. So I'll look into that tomorrow, but just in case this is an issue, wanted to put the feelers out to see if anyone else has had this issue.

Thank you.