2013-01-16 51 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

相關問題