2

私のJavaコードをマーシャリングしている間:

      Marshaller marshaller = context.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
      marshaller.marshal(um, new File("temp.xml"));

私はこの例外を得ました:

Exception in thread "main" javax.xml.bind.JAXBException: class com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl nor any of its super class is known to this context.
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)
    at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)
    at App.main(App.java:47)
4

2 に答える 2

1

例外の原因となっている可能性のあることがいくつかあります。

可能性 #1

ドメイン オブジェクトの 1 つが のインスタンスを保持していますUnmarshallerImpl。これをしないことをお勧めします。しなければならないと感じた場合は、そのフィールド/プロパティに で注釈を付ける必要があります@XmlTransient

可能性その2

Ian Roberts のコメントで示唆されているようUnmarshallerImplに、um変数のインスタンスを誤ってマーシャリングしている可能性がありますUnmarshaller

于 2013-06-27T11:06:19.733 に答える
-1

おそらく、javax.xml.bind の代わりに com.sun.xml.internal.bind のリソースをインポートします。

于 2013-06-27T13:31:17.203 に答える