1

Xstream を使用して Groovy ドメイン クラスの従業員の 1 つをマーシャリングしようとすると、以下のエラーが発生します。Employee には、Skill および Employee に属する多くのemployeDesiredSkills があります。

関連する Xstream コードは次のとおりです。

employeeInstance = new Employee();
XStream xstream = new XStream();

Xstream.alias("employee", Employee.class);

String xml = xstream.toXML(employeeInstance);

Employee クラスには、ArrayLists として明示的に定義された employeeDesiredSkills があります。エラーメッセージが何を言っているのかよくわかりません。「C 開発」が EmployeeDesiredSkill としてデータベースに保存された項目の 1 つであったことだけは知っています。

2010-09-21 18:13:13,911 [http-8080-1] ERROR errors.GrailsExceptionResolver  - Cannot    reference implicit element
---- Debugging information ----
implicit-element    : C Development
referencing-element : /employee/employeeDesiredSkills/storedSnapshot/EmployeeDesiredSkill/skill/roleSkills/owner
-------------------------------
com.thoughtworks.xstream.core.AbstractReferenceMarshaller$ReferencedImplicitElementException: Cannot reference implicit element
---- Debugging information ----
implicit-element    : C Development
referencing-element : /employee/employeeDesiredSkills/storedSnapshot/EmployeeDesiredSkill/skill/roleSkills/owner

-------------------------------
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:58)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:157)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:148)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:118)
    at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:129)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:100)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:58)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:157)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:148)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:118)
    at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:129)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:100)
4

1 に答える 1

0

例外を考えると、要素には、オブジェクトEmployeeで明示的にエイリアス化する必要のあるフィールドがあるようです。XStream

私はあなたのドメインと環境をよく理解していないので、具体的な提案をすることはできません。ただし、問題が解決するまでエイリアシングをいじってみてください。

omitField()デバッグ方法として、すべてのプロパティでXStreamを使用しEmployeeてから、問題の原因が特定されるまで一度に1つずつ削除してみてください。そこからドリルダウンできます。

于 2010-09-22T00:37:40.447 に答える