jaxb unmarshal problem
- by Hoax
private JAXBContext jaxbContext;
private Marshaller marshaller;
private Unmarshaller unmarshaller;
private PoiList db;
public XMLHandler() {
try {
JAXBContext.newInstance("x.y.shared");
} catch (JAXBException e) {
e.printStackTrace();
}
}
public PoiList readXML() {
try {
unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setEventHandler(new XMLValidEventHandler());
db = (PoiList) unmarshaller.unmarshal(new File("src/source.xml"));
} catch (JAXBException e) {
e.printStackTrace();
}
return db;
}
gets me this
Exception in thread "main" java.lang.NullPointerException
at com.sem.server.XMLHandler.readXML(XMLHandler.java:32)
at sem.server.testDataAPI.main(testDataAPI.java:13)
Line 32 in this case is the jaxbContext.createUnmarshaller() Line.
packages are
x.y.client
x.y.server (includes the XMLHandler)
x.y.shared (includes jaxb generated classes)
not really sure what the problem is. any help is appreciated!