XStream
  1. XStream
  2. XSTR-449

Cannot deserialize a class with org.jdom.Element

    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

        People

        • Assignee:
          Unassigned
          Reporter:
          Arun
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: