Java Jersey Jettison Message Body Reader异常 [英] Java Jersey Jettison Message Body Reader Exception

查看:643
本文介绍了Java Jersey Jettison Message Body Reader异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是REST服务的完全初学者,但我需要通过REST从网站访问一些信息。该服务有一些示例代码,以显示如何登录我使用过。示例代码使用Jettison作为JSON解析器,但是当我尝试运行以下代码片段时,我得到一个异常:

I am a complete beginner at REST services but I need to access some information via REST from a web site. The service has some sample code to show how to login that I have used. The sample code uses Jettison as a JSON parser but when I try to run the following code snippet I get an Exception:

JSONObject post = baseResource.path("login")
            .queryParam("service", "ABC").queryParam("auth", authParam)
            .accept(MediaType.APPLICATION_JSON_TYPE).post(JSONObject.class);

baseResourse是一个WebResource对象。代码失败,出现以下异常:

baseResourse is a WebResource object. The code fails with the following exception:

Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException:
A message body reader for Java class org.codehaus.jettison.json.JSONObject, and
Java type class org.codehaus.jettison.json.JSONObject, and MIME media type
application/json; character=utf-8 was not found

示例代码并不表示我需要添加任何内容消息体读者处理响应?或者我是否需要添加或执行任何明显的解析响应?谢谢。

The sample code does not suggest that I should need to add any "message body readers" to handle the response? Or do I need to add or do anything obvious to parse the response? Thanks.

推荐答案

您需要在类路径中包含jersey-json模块。请参见 http://jersey.java.net/nonav/documentation/latest/ chapter_deps.html#d4e1817

You need to include jersey-json module on your classpath. See http://jersey.java.net/nonav/documentation/latest/chapter_deps.html#d4e1817

这篇关于Java Jersey Jettison Message Body Reader异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆