title: Xstream incorrectly interpreting a list item as part of another list item
body: <p>I am trying to read from an XML file using Xstream.  The weird issue I am having is that when I make a list of users, it reads the first user correctly, but <strong>it tries to store the <em>second</em> user as a member variable of the <em>first</em></strong>!  I have this XML file:</p>
  
  <pre><code>&lt;data&gt;
      &lt;users&gt;
          &lt;user&gt;
              &lt;username&gt;test1&lt;/username&gt;
              &lt;password&gt;test1&lt;/password&gt;
              &lt;firstname&gt;Test&lt;/firstname&gt;
              &lt;lastname&gt;One&lt;/lastname&gt;
              &lt;email&gt;test1@gmail.com&lt;/email&gt;
              &lt;indexedrecords&gt;0&lt;/indexedrecords&gt;
          &lt;/user&gt;
          &lt;user&gt;
              &lt;username&gt;test2&lt;/username&gt;
              &lt;password&gt;test2&lt;/password&gt;
              &lt;firstname&gt;Test&lt;/firstname&gt;
              &lt;lastname&gt;Two&lt;/lastname&gt;
              &lt;email&gt;test2@gmail.com&lt;/email&gt;
              &lt;indexedrecords&gt;0&lt;/indexedrecords&gt;
          &lt;/user&gt;
      &lt;/users&gt;
      .... There are other tags here, but they're not causing an issue (yet).
  &lt;/data&gt;
  </code></pre>
  
  <p>The code for the Xstream reader:</p>
  
  <pre><code>XStream xstream = new XStream(new StaxDriver());
  xstream.addImplicitCollection(Model.class, "users", User.class);
  
  @SuppressWarnings("rawtypes")
  Class[] classes = new Class[2];
  classes[0] = Model.class;
  classes[1] = User.class;
  xstream.processAnnotations(classes);
  
  String xml = "";//The XML is really stored here, and it does work correctly
  xstream.fromXML(xml);
  </code></pre>
  
  <p>And the classes themselves.  Model:</p>
  
  <pre><code>@XStreamAlias("data")
  public class Model {
      @XStreamImplicit
      public static List&lt;User&gt; users;
      //Other stuff
  }
  </code></pre>
  
  <p>User:</p>
  
  <pre><code>@XStreamAlias("user")
  public class User implements ModelItem{
      private String username;
      private String password;
      @XStreamAlias("firstname")
      private String firstName;
      @XStreamAlias("lastname")
      private String lastName;
      private String email;
      @XStreamAlias("indexedrecords")
      private int recordsIndexed;
  }
  </code></pre>
  
  <p>The exeption (pardon the <code>[java]</code> - it's being run using ANT):</p>
  
  <pre><code> [java] Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: Element user of type shared.model.User is not defined as field in type shared.model.User
   [java] ---- Debugging information ----
   [java] class               : shared.model.User
   [java] required-type       : shared.model.User
   [java] converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
   [java] path                : /data/users/user
   [java] line number         : 19
   [java] class[1]            : indexer.shared.model.Model
   [java] version             : null
   [java] -------------------------------
   [java]     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.writeValueToImplicitCollection(AbstractReflectionConverter.java:403)
   [java]     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:334)
   [java]     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
   [java]     at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   [java]     at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   [java]     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   [java]     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
   [java]     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:322)
   [java]     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
   [java]     at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   [java]     at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   [java]     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   [java]     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
   [java]     at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
   [java]     at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
   [java]     at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1052)
   [java]     at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1036)
   [java]     at com.thoughtworks.xstream.XStream.fromXML(XStream.java:912)
   [java]     at com.thoughtworks.xstream.XStream.fromXML(XStream.java:903)
   [java]     at importer.Importer.importXml(Importer.java:77)
   [java]     at importer.Importer.main(Importer.java:45)
  </code></pre>
  
  <p>Why is Xstream trying to store the second <code>User</code> as a variable inside the first <code>User</code>?</p>
  
  <p><strong>Answer Edit:</strong>  There were two problems, both addressed in Michael's answer.</p>
  
  <p>1) I was implying an implicit collection (twice!) which I should not have done, since the XML explicitly declares a <code>users</code> list.</p>
  
  <p>2) My variables in the <code>Model</code> class was static.  It is unclear as to why this caused an error, but it did cause it nevertheless.</p>