I wrote a java application (commandline app) initially and now I am trying to convert it to a web application using jersey and jetty embeded. Now as the output of a service rest class I need to output a List<List<Map<String,String>>>
in json format. Is there a way to accomplish this? I am new to the world of servlets and stuff.. i tried like this :
@GET
@Path("test")
@Produces(MediaType.APPLICATION_JSON)
public List>> test( ) throws FileNotFoundException, IOException, GateException, URISyntaxException {
System.out.println("Starting the App");
System.out.println("Locations added successfully");
DataFile file = new CSVDataFile();
CommandsExecutor.outputsList.add(0, file.performReadOperation(inputFilePath));
System.out.println("Begining execution");
List<List<Map<String, String>>> finalOutput = CommandsExecutor.executeSequentialCommands(file);
/* for (List<Map<String, String>> tmpList : finalOutput) {
for (int i = 0; i < tmpList.size(); i++) {
Map<String, String> insideMap = tmpList.get(i);
// for (Map.Entry<String, String> entry : insideMap.entrySet())
// {
// System.out.println(entry.getKey() + "/" + entry.getValue());
// }
JSONObject obj = new JSONObject(insideMap);
System.out.println(obj);
}
System.out.println("\n");
} */
return finalOutput;
}
Now I get an error like this : Could not send response error 500: javax.servlet.ServletException: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List>>.
What could be the work around ? Thanks in advance!!
>>)** is because you are doing something wrong
– M. Mariscal Mar 30 '16 at 20:52