I'm creating a web application. I want to do the admin operations using Java SE application. To do that I created a RESTful ShoppingAdminClient
in my SE project. I need to pass an JSON object to the server from client. I tried with this,
public static void main(String[] args) throws JSONException {
ShoppingAdminClient sac = new ShoppingAdminClient();
JSONObject jo = new JSONObject();
jo.put("itemName", "Itemms");
sac.create_JSON(jo);
}
But I got the following exception,
Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class shoppingadmin.Item, 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.post(WebResource.java:563)
at shoppingadmin.ShoppingAdminClient.create_JSON(ShoppingAdminClient.java:69)
at shoppingadmin.ShoppingAdmin.main(ShoppingAdmin.java:27)
Caused by: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class shoppingadmin.Item, and MIME media type, application/json, was not found
at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:288)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:204)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:147)
... 6 more
Java Result: 1
How do I pass a JSON type object to server?
Thanks in Advance!