Search code examples
javaclasspathxstream

Working with Xstream, clarification needed


Consider a simple Xsctream example to create JSON out of the Bean:

Bean bean = new Bean();
bean.addNames("John", "Doe");
bean.addNames("Jane", "Doe");

XStream xstream = new XStream(new JettisonMappedXmlDriver());    
xstream.setMode(XStream.NO_REFERENCES);

System.out.println(xstream.toXML(bean));

results in

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jettison/mapped/Configuration
    at com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver.<init>(JettisonMappedXmlDriver.java:55)
    at Main.main(Main.java:12)

Note that libraries are imported as they should be

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;

And proper jars are included

enter image description here


Solution

  • You need jettison.jar from codehaus click this link