我解编时XML和Java对象与JAXB有一个错误:如何调试这个NullPointerException异常
java.lang.NullPointerException
at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$1.parse(RuntimeBuiltinLeafInfoImpl.java:188)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$1.parse(RuntimeBuiltinLeafInfoImpl.java:186)
at com.sun.xml.internal.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:230)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:50)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:483)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.text(InterningXmlVisitor.java:78)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXEventConnector.handleCharacters(StAXEventConnector.java:173)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(StAXEventConnector.java:127)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:392)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:368)
我怎样才能找到原因?
一些更多的细节:我试图解析XML的
部分是:
<member_resources>
<__field_location__>
<directive>
sun-sat
</directive>
<file>
null
</file>
<line>
0
</line>
</__field_location__>
<sun-sat>
00:00-24:00 tester2
</sun-sat>
<__field_location__>
<directive>
isLine
</directive>
<file>
null
</file>
<line>
0
</line>
</__field_location__>
<isLine>
true
</isLine>
</member_resources>
在引起该事件停止时,我得到:
next event <__field_location__>
next event <directive>
next event sun-sat
next event <file>
next event null
你在用什么IDE?如果它是Eclipse或Netbeans,你可以使用它们的调试器。 – talnicolas 2012-02-27 14:05:15
请张贴一些代码。 – 2012-02-27 14:05:38
发现问题: 我正在使用我自己的xml事件解组。 'new CharactersImpl(key)'的代码将导致这个异常,如果key是'null'的话。 – oshai 2012-02-27 14:19:17