2012-02-27 2 views
1

をデバッグすることができJAXBとJavaオブジェクトにXMLをマーシャリング解除するとき、私はエラーを持っている:はどのように私はこの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 
+0

どのIDEを使用していますか? EclipseまたはNetbeansの場合は、デバッガを使用できます。 – talnicolas

+0

コードを記入してください。 –

+0

問題が見つかりました: 私は自分自身のXMLイベントを非マーシャルに使用しています。 keyが 'null'の場合には' new CharactersImpl(key) 'というコードでこの例外が発生します。 – oshai

答えて

3

NullPointerExceptionの例外ブレークポイントを追加します。ヒットしたら、コールスタックのいくつかのレベルを調べてローカル変数の状態を調べると、おそらくヌルであるかどうかのヒントが得られます。

1

unmarshalerへの呼び出しでブレークポイントを設定し、渡されている引数を正確に確認することができます。

私が調べる最初のことは、あなたが渡しているものは実際にはXMLであり、それは整形式で有効であるということです。

3

良いアプローチは、JAXB(その実装)のソースとデバッグ用のIDEを使用しています。

関連する問題