我已经为我的 XML 创建了一个结构来使用 JAXB 解组 问题是 taht,Unmarshaller 没有被创建。
JAXBContext jc = JAXBContext.newInstance("A Fully qualified class name");
Unmarshaller um = jc.createUnmarshaller();
java.lang.NullPointerException is being thrown at
Unmarshaller um = jc.createUnmarshaller();
除了 java.lang.NullPointerException 之外,statcktrace 上没有任何内容,因此也无法对其进行调试。有人可以告诉我在创建 Unmarshaller 期间如何解决这个问题吗?对于 JAXB 2.0
供参考,这是我的 Parser 类
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();
}
}