I have created a Structure for my XML to work with JAXB Unmarshalling
The problem is taht , the Unmarshaller is not being getting created .
JAXBContext jc = JAXBContext.newInstance("A Fully qualified class name");
Unmarshaller um = jc.createUnmarshaller();
java.lang.NullPointerException is being thrown at
Unmarshaller um = jc.createUnmarshaller();
There is nothing on to the statcktrace except java.lang.NullPointerException , so cant able to debug it also .
Could anybody please tell me how to solve this during creating a Unmarshaller ?? for JAXB 2.0
For refernece this is my Parser class
public class BADFMMessageParser {
private static JAXBContext jc = null;
static {
try {
jc = JAXBContext.newInstance("My Fully Qualified class name");
} catch (Exception x) {
}
}
public static MyClass parse(String str) throws Exception {
Unmarshaller um = jc.createUnmarshaller();
BADFM badfmMessage = (BADFM) um.unmarshal(new StringReader(requestStr));
JAXBElement<? extends MyClass> value = badfmMessage.getMessage();
return value.getValue();
}
}
I’m not sure why you are seeing a NPE, but you appear to be creating your
JAXBContextincorrectly. You could do the following assuming you had ajaxb.indexfile orObjectFactoryclass in the specified package:Otherwise you could create your
JAXBContextdirectly on the class or classes:jaxb.indexFile ExampleBootstrap
JAXBContexton Generated Model ExampleBootstap
JAXBContextfrom Classes Example