I am working on RestFul Webservice, I wrote a small reassured service that returns json data, here is my code:
@Path("/test")
public class TestService {
@GET
@Produces(MediaType.APPLICATION_JSON)
public String sayHello() {
return "<h6> Hello, Welcome to the world of REST (Plain Text) </h6>";
}
@GET
@Path("dbdetails")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, List> getDBDetails() {
System.out.println("ramesh kumar ");
List<ProductCategories> list = new ArrayList<ProductCategories>();
HashMap<String,List> map = new HashMap<String,List>();
ProductCategories cat = new ProductCategories();
cat.setId(1);
cat.setImage("Image21");
cat.setName("Electronics");
cat.setRowid(111);
cat.setType("CatType");
list.add(cat);
map.put("Ramesh",list);
System.out.println("ramesh kumar ");
return map;
}
But I get an error message:
SEVERE: message body writer for type Java, class java.util.HashMap, and media type MIME, application / json, not found March 3, 2011 3:32:41 PM com.sun.jersey.server.impl.application.WebApplicationImpl onException SEVERE: internal javax.ws.rs.WebApplicationException server error
Any ideas?
source
share