I have a method which is returning Map<String, ArrayList<EntityClass>>
. code is as follow of Definition
class:
public Map<String, ArrayList<EntityClass>> webMethod1(){
ArrayList<EntityClass> arr = new ArrayList<>();
for (int i=0;i<5;i++){
arr.add(new EntityClass(i, String.valueOf(i)));
}
Map<String, ArrayList<EntityClass>> map = new HashMap<>();
map.put("Entity", arr);
}
Further this is called by a web service as follow:
@GET
@Path("/m1")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, ArrayList<EntityClass>> m1(){
return new Definition().webMethod1();
}
but i am getting following on the console:
MessageBodyWriter not found for media type=application/json, type=class java.util.HashMap, genericType=class java.util.HashMap.
and HTTP 500
as error.
how to resolve this error