I have a container class as follows:
class FruitBasket { List<Apple> apples; List<Orange> oranges;}
I have added xstream.registerConverter(new 
HibernatePersistentCollectionConverter(xstream.getMapper()));I have also setup 
alias apple for com.myorg.Apple and com.myorg.Orange.
The marshalled FruitBasket object has:
<apples class="list">  <apple>....</apple>  
<apple>....</apple></apples><oranges class="list">  <orange>....</orange>  
<orange>....</orange></oranges>
In order to get rid of the class="list" in apples and oranges, I added 
xstream.alias("apples", List.class, 
PersistentList.class);xstream.alias("oranges", List.class, 
PersistentList.class); The objects are marshalled all right, without the class= 
attributes.
But the client unmarshals, and fails with 
com.thoughtworks.xstream.mapper.CannotResolveClassException: oranges 
If I change the order of aliasing with oranges first instead of 
apples:xstream.alias("oranges", List.class, 
PersistentList.class);xstream.alias("apples", List.class, PersistentList.class);
then the CannotResolveClassException comes for apples.
Seems like at most one collection of the same interface type (List in this 
case) is end-to-end marshalled / unmarshalled all right for the FruitBasket 
container class.
I would like to know if there is a way around the problem.
                                          

Reply via email to