title: Parsing XML having list of objects into javaobject using Xstream
body: <p>I want to convert a XML to java object using Xstream. Below is how my implementation to do this.</p>
  
  <p>I have a XML which looks like:</p>
  
  <pre><code>&lt;CWATSR&gt;
  &lt;ATSP&gt;
      &lt;Keys&gt;spacekey1&lt;/Keys&gt;
      &lt;Keys&gt;spacekey2&lt;/Keys&gt;
      &lt;Keys&gt;spacekey3&lt;/Keys&gt;
      &lt;STATM&gt;
          &lt;entry&gt;
              &lt;key&gt;Test1&lt;/key&gt;
              &lt;value&gt;Test1value&lt;/value&gt;
          &lt;/entry&gt;
          &lt;entry&gt;
              &lt;key&gt;Test2&lt;/key&gt;
              &lt;value&gt;Test2value&lt;/value&gt;
          &lt;/entry&gt;
          &lt;entry&gt;
              &lt;key&gt;ITest3&lt;/key&gt;
              &lt;value&gt;Test3Value&lt;/value&gt;
          &lt;/entry&gt;
      &lt;/STATM&gt;
  &lt;/ATSP&gt;
  &lt;ATSP&gt;
      &lt;Keys&gt;spacekey11&lt;/Keys&gt;
      &lt;Keys&gt;spacekey22&lt;/Keys&gt;
      &lt;Keys&gt;spacekey33&lt;/Keys&gt;
      &lt;STATM&gt;
          &lt;entry&gt;
              &lt;key&gt;Test1&lt;/key&gt;
              &lt;value&gt;Test1value1&lt;/value&gt;
          &lt;/entry&gt;
          &lt;entry&gt;
              &lt;key&gt;Test2&lt;/key&gt;
              &lt;value&gt;Test2value2&lt;/value&gt;
          &lt;/entry&gt;
          &lt;entry&gt;
              &lt;key&gt;ITest3&lt;/key&gt;
              &lt;value&gt;Test3Value3&lt;/value&gt;
          &lt;/entry&gt;
      &lt;/STATM&gt;
  &lt;/ATSP&gt;
  &lt;/CWATSR&gt;
  </code></pre>
  
  <p>and I have 2 java objects for which I want to convert the above XML using Xstream:</p>
  
  <p>CWATST.class</p>
  
  <pre><code>@XStreamAlias("CWATSR")
  public class CWATSR {
  
      @XStreamImplicit
      private List&lt;ATSP&gt; atsp;
  
      //Getters and setters
  }
  </code></pre>
  
  <p>WrappedReflectingDefinition.class</p>
  
  <pre><code>@XStreamAlias("ATSP")
  public class ATSP implements Serializable {
  
      @XStreamImplicit(itemFieldName = "Keys")
      @XmlElement(name = "Keys")
      private List&lt;String&gt; Keys;
  
      @XStreamAlias("STATM")
      private Map&lt;String, String&gt; STATM;
  
      // Getters and setters
  
  }
  </code></pre>
  
  <p>My Xstream code is (body is the XML stated above):</p>
  
  <pre><code>xstream.processAnnotations(CWATSR .class);
  xstream.processAnnotations(ATSP.class);
  CWATSR cwatsr = (CWATSR ) xstream.fromXML(body);
  </code></pre>
  
  <p>I get the following exception:</p>
  
  <pre><code>Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: Keys:Keys
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
      at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:464)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:396)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:247)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
      at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
      at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
      at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1156)
      at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1140)
      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1011)
      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1002)
      at com.iit.package.delete.main(delete.java:53)
  Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: Keys
      at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:79)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
      at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:45)
      at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
      at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:70)
      at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:98)
      at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:91)
      at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:85)
      at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:80)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
      ... 16 more
  </code></pre>