I use XStream under Kettle to deserialize XML to a Java object and always give me an exception: nodecom.thoughtworks.xstream.mapper.CannotResolveClassException
Then I tried my code separately from Kettle and as a simple Java application. and it works great. For instance:
public static void main(String[] args) { person p = new person("JJ", "MM"); XStream xstream = new XStream(new DomDriver()); xstream.alias("personname", person.class); String xml = xstream.toXML(p); person pp = (person) xstream.fromXML(xml); System.out.println(pp.toString()); } public class person { private String firstname; private String lastname; public person(String first, String last) { this.firstname = first; this.lastname = last; } public String getFirstname() { return this.firstname; } public String getLastname() { return this.lastname; } public void setFirstname(String name) { this.firstname = name; } public void setLastname(String name) { this.lastname = name; } }
And this code is working fine. However, when I move this code to the Kettle plugin, it does not work at the stage of reading metadata from the XML file.
source share