我解編時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