2013-01-16 48 views
0

我得到以下异常,同时试图把JSONOBbject像 inputData: { “键1”: “值1”, “KEY2”: “值2” }Jersey客户端API抛出异常的PUT请求的JSONObject

代码片段:

  WebResource webResource = client 
       .resource(url); 
    response = webResource.type(MediaType.APPLICATION_JSON_TYPE) 
       .put(ClientResponse.class,inputData); 

例外:

 com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class org.json.JSONObject, and MIME media type, application/json, was not found 
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) 
at com.sun.jersey.api.client.Client.handle(Client.java:648) 
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670) 
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) 
at com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:533) 
at httptransaction.CommonHttpClient.doPutConnect(CommonHttpClient.java:222) 

个分辨率任何指针?

+0

你不认为你需要org.json库序列化到JSON。只是通过在正常的POJO实体,也许。 – miguelcobain

+0

对不起,*我不认为 – miguelcobain

回答

0

你需要在你的classpath的球衣,JSON JAR。

+0

我确实有球衣,JSON 1.16添加Maven的依赖在类路径中 – tester

+0

我有相同的问题,但球衣JSON的1.5。 – Hakkar

相关问题