Hi Tobias,

Tobias Gierke wrote:

> Hi,
> 
> We recently started getting weird XStream errors on code that was
> previously working fine. IMHO some (seemingly unreleated) change causes
> the serialization to output bad XML and this in turn makes the
> deserialization fall over later on.
> 
> The error message I'm getting is:
> 
> com.thoughtworks.xstream.converters.ConversionException: Cannot
> deserialize object with new readObject()/writeObject() methods
> ---- Debugging information ----
> class               : java.util.HashSet
> required-type       : java.util.HashSet
> converter-type      :
> com.thoughtworks.xstream.converters.reflection.SerializableConverter
> path                :
> 
/com.vodecc.voipmng.boundary.wicket.streamsearch.StreamSearchResultsPage/children/com.vodecc.voipmng.boundary.wicket.general.UserInfoPanel/children/com.vodecc.voipmng.boundary.wicket.general.UserInfoPanel$UserEditableFragment/children/children/data/org.apache.wicket.model.PropertyModel/target/roles
> line number         : 1
> class[1]            : com.vodecc.voipmng.core.usermng.entity.CVod_UserBean
> converter-type[1]   :
> com.thoughtworks.xstream.converters.reflection.ReflectionConverter
> class[2]            : org.apache.wicket.model.PropertyModel
> class[3]            : [Ljava.lang.Object;
> converter-type[2]   :
> com.thoughtworks.xstream.converters.collections.ArrayConverter
> class[4]            : org.apache.wicket.markup.html.basic.Label
> class[5]            :
> com.vodecc.voipmng.boundary.wicket.integration.StrutsActionLink
> class[6]            :
> 
com.vodecc.voipmng.boundary.wicket.general.UserInfoPanel$UserEditableFragment
> class[7]            :
> com.vodecc.voipmng.boundary.wicket.general.UserInfoPanel
> class[8]            :
> com.vodecc.voipmng.boundary.wicket.streamsearch.StreamSearchResultsPage
> version             : not available
> 
> The weird thing is this:
> 
> I created a stand-alone unit-test that serializes & deserializes a
> org.apache.wicket.model.PropertyModel that wraps a "CVod_UserBean"
> instance with a non-empty "roles" HashSet and it works just fine (see
> attached file working.xml). It's just not working when serializing the
> whole Apache Wicket page.
> 
> As a side note, the "roles" attribute actually holds a Hibernate
> PersistentSet. I'm using the HibernatePersistentCollectionConverter to
> handle this , after changing my unit-test to use PersistentSet instead
> of java.util.HashSet it still working correctly.
> 
> Comparing the working/broken (see attachments) I see that the *broken*
> XML lacks 'serialization='custom' attributes ... what is the meaning of
> these attributes and what might be the reason why their missing in the
> broken XML (both using an XStream instance with identical
> mappers/converters) ?
> 
> This is with XStream 1.4.8 and JDK 1.8.0_40 on 64-bit Linux.

You face a version problem in your object model. The problem simply 
indicates that the type of the instance used in the "roles" field of 
CVod_UserBean is different now.

Compare the following output:

 HashSet<EVF_Permission> hs1 = new HashSet<>();
 hs1.add(EVF_Permission.EXPORT_SIP_TRUNKS);
 HashSet<EVF_Permission> hs2 = new HashSet<>() {};
 hs2.add(EVF_Permission.EXPORT_SIP_TRUNKS);
 System.out.println(xstream.toXML(hs1));
 System.out.println(xstream.toXML(hs2));

You will see in the similar differences to your XML examples.

The first instance is actually handled by the CollectionConverter while the 
second instance is handled by the SerializationConverter. Therefore you see 
a different XML representation.

So, what has actually be changed?

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to