开发者

ERROR errors.GrailsExceptionResolver - Cannot reference implicit element

开发者 https://www.devze.com 2023-01-17 14:25 出处:网络
I am getting the below error when I try to use Xstream to marshal one of my groovy domain classes Employee. Employee hasmany employeDesiredSkills, which belongsTo Skill and Employee

I am getting the below error when I try to use Xstream to marshal one of my groovy domain classes Employee. Employee hasmany employeDesiredSkills, which belongsTo Skill and Employee

Here is the relevant Xstream code

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

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

String xml = xstream.toXML(employeeInstance);

Employee class has the employeeDesiredSkills explicity defined as ArrayLists. I'm not real sure what error message is saying. I just know that "C Development" was one of the items saved as an EmployeeDesiredSkill in the database

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/开发者_如何学JAVAstoredSnapshot/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)


Given the Exception, it looks like your Employee element may have a field that needs to be aliased explicitly in your XStream object.

I can't offer any concrete suggestions as I don't have a great understanding of your domain and environment. However, you might try messing with the aliasing until you get things right.

As a debugging method, you might try using XStream's omitField() on ALL of the Employee properties and then remove them one at a time until you find out which one is causing the problem. You can drill down from there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号