jaxb unmarshal problem

Posted by Hoax on Stack Overflow See other posts from Stack Overflow or by Hoax
Published on 2010-06-10T23:57:51Z Indexed on 2010/06/11 0:02 UTC
Read the original article Hit count: 253

Filed under:
    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!

© Stack Overflow or respective owner

Related posts about jaxb