jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-449

Cannot deserialize a class with org.jdom.Element

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2.1
  • Fix Version/s: 1.2.2
  • Component/s: Core
  • Labels:
    None
  • JDK version and platform:
    Java 1.4.2_08

Description

Hello,

I have a class with a field of type org.jdom.Element. When I try to serialize that class it get properly serialized. But during de-serialization process I am getting the following exception.

%<--------------------------------------------------------------------------------------------------------------------------------------
Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: Could not call org.jdom.Element.readObject()
---- Debugging information ----
message : Could not call org.jdom.Element.readObject()
cause-exception : java.lang.UnsupportedOperationException
cause-message : null
class : TestClass
required-type : org.jdom.Element
path : /TestClass/element/org.jdom.Element
class : TestClass
required-type : org.jdom.Element
path : /TestClass/element/org.jdom.Element
-------------------------------
at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callReadObject(SerializationMethodInvoker.java:77)
at com.thoughtworks.xstream.converters.reflection.SerializableConverter.doUnmarshal(SerializableConverter.java:365)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:121)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:197)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:169)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:121)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:832)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:819)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:767)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:759)
at XMLUtilTest.main(XMLUtilTest.java:75)
Caused by: java.lang.UnsupportedOperationException
at com.thoughtworks.xstream.core.util.CustomObjectInputStream.read(CustomObjectInputStream.java:215)
at org.jdom.Element.readObject(Element.java:1340)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callReadObject(SerializationMethodInvoker.java:73)
... 18 more

-------------------------------------------------------------------------------------------------------------------------------------- >%

I am using the following method for serialization,

String xmlString = new XStream(new JDomDriver()).toXML(new TestClass());

and if I deserialize the same xmlString using the following code,

TestClass test = (TestClass) new XStream(new JDomDriver()).fromXML(xmlString);

I am getting the above mentioned exception. If I make the field of type org.jdom.Element to transient no exception occurs.

Please provide your comment...

Best Regards
Arun K

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Arun added a comment - 15/Nov/07 2:07 AM

Additionally the following is my class,

public class TestClass implements Serializable {
private String name;
private Integer rollNr;
private BigDecimal percentage;
private Double totalMarks;
private org.jdom.Element element;
public TestClass() { this.name = "arun"; this.rollNr = new Integer(1001); this.percentage = new BigDecimal("86.00"); this.totalMarks = new Double(80); this.element = new Element("test"); }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public BigDecimal getPercentage() { return percentage; }
public void setPercentage(BigDecimal percentage) { this.percentage = percentage; }
public Integer getRollNr() { return rollNr; }
public void setRollNr(Integer rollNr) { this.rollNr = rollNr; }
public Double getTotalMarks() { return totalMarks; }
public void setTotalMarks(Double totalMarks) { this.totalMarks = totalMarks; }
public Element getElement() { return element; }

public void setElement(Element element) { this.element = element; }

}

and the serilized form is as below,

<TestClass>
<name>ARN</name>
<rollNr>1003</rollNr>
<percentage>89.50</percentage>
<totalMarks>899.0</totalMarks>
<element serialization="custom">
<org.jdom.Element>
<default>
<attributes>
<size>0</size>
<parent reference="../../../.."/>
</attributes>
<content>
<elementData>
<org.jdom.Text>
<value>Arun</value>
<parent class="org.jdom.Element"
reference="../../../../../.."/>
</org.jdom.Text>
<null/>
<null/>
<null/>
<null/>
</elementData>
<size>1</size>
<parent class="org.jdom.Element" reference="../../../.."/>
</content>
<name>new_test</name>
</default>
<string></string>
<string></string>
<byte>0</byte>
</org.jdom.Element>
</element>
</TestClass>

Show
Arun added a comment - 15/Nov/07 2:07 AM Additionally the following is my class, public class TestClass implements Serializable { private String name; private Integer rollNr; private BigDecimal percentage; private Double totalMarks; private org.jdom.Element element; public TestClass() { this.name = "arun"; this.rollNr = new Integer(1001); this.percentage = new BigDecimal("86.00"); this.totalMarks = new Double(80); this.element = new Element("test"); } public String getName() { return name; } public void setName(String name) { this.name = name; } public BigDecimal getPercentage() { return percentage; } public void setPercentage(BigDecimal percentage) { this.percentage = percentage; } public Integer getRollNr() { return rollNr; } public void setRollNr(Integer rollNr) { this.rollNr = rollNr; } public Double getTotalMarks() { return totalMarks; } public void setTotalMarks(Double totalMarks) { this.totalMarks = totalMarks; } public Element getElement() { return element; } public void setElement(Element element) { this.element = element; } } and the serilized form is as below, <TestClass> <name>ARN</name> <rollNr>1003</rollNr> <percentage>89.50</percentage> <totalMarks>899.0</totalMarks> <element serialization="custom"> <org.jdom.Element> <default> <attributes> <size>0</size> <parent reference="../../../.."/> </attributes> <content> <elementData> <org.jdom.Text> <value>Arun</value> <parent class="org.jdom.Element" reference="../../../../../.."/> </org.jdom.Text> <null/> <null/> <null/> <null/> </elementData> <size>1</size> <parent class="org.jdom.Element" reference="../../../.."/> </content> <name>new_test</name> </default> <string></string> <string></string> <byte>0</byte> </org.jdom.Element> </element> </TestClass>
Hide
Permalink
Arun added a comment - 29/Nov/07 5:10 AM

Hi All,

I checked the same with XStream version 1.2.2 and it seems to be working. I checked the change log for major/minor fixes, but couldn't find any references. Can anybody provide some references for the problem.

Arun

Show
Arun added a comment - 29/Nov/07 5:10 AM Hi All, I checked the same with XStream version 1.2.2 and it seems to be working. I checked the change log for major/minor fixes, but couldn't find any references. Can anybody provide some references for the problem. Arun
Hide
Permalink
Joerg Schaible added a comment - 30/Nov/07 7:08 PM

Difficult to say now. It might have been one of the things we changed to support the field sorting. The problem with the reported exception is, that it normally hides the real problem, why readObject failed in first place. The error message "could not call readObject" is somewhat misleading here.

Show
Joerg Schaible added a comment - 30/Nov/07 7:08 PM Difficult to say now. It might have been one of the things we changed to support the field sorting. The problem with the reported exception is, that it normally hides the real problem, why readObject failed in first place. The error message "could not call readObject" is somewhat misleading here.
Hide
Permalink
Joerg Schaible added a comment - 30/Nov/07 7:09 PM

Corrected fixed version.

Show
Joerg Schaible added a comment - 30/Nov/07 7:09 PM Corrected fixed version.

People

  • Assignee:
    Unassigned
    Reporter:
    Arun
Vote (0)
Watch (1)

Dates

  • Created:
    15/Nov/07 1:53 AM
    Updated:
    30/Nov/07 7:09 PM
    Resolved:
    30/Nov/07 7:09 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.