I have looked around on the web but can seem to get this working. I have a web service where i am trying to read JSON but i keep getting an error when i create the XStream object. here is the code i have and the error
public static InputDTO inputFromJson(HttpServletRequest request) throws IOException {
logger.debug("in inputfromjson");
XStream xstreamJson = new XStream(new JettisonMappedXmlDriver()); //this is where the code starts failing
logger.debug("after xstreamjson create");
xstreamJson.alias("tz", String.class);
InputDTO inputDTO = null;
try (InputStream is = request.getInputStream())
{
Object dto = xstreamJson.fromXML(is);
if (dto instanceof InputDTO) {
inputDTO = (InputDTO)dto;
}
}
logger.debug(inputDTO);
return inputDTO;
}
The error i am getting is
java.lang.ClassNotFoundException: org.codehaus.jettison.mapped.Configuration
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver.<init>(JettisonMappedXmlDriver.java:48)
at com.homedepot.week3.XMLReader.inputFromJson(XMLReader.java:81)
I have read that i need to import the org.codehaus.jettison.json.*; but that doesn't seem to fix anything. Could someone please help with this? I'm sure its something simple.
Thanks!