title: xstream errors for serializing & deserializing
body: <p>I am using xStream in Java to serialize a java object from a java library and deserializing it at the customer's side.</p>
  
  <p>I have several problems:</p>
  
  <p>If I do it like this:</p>
  
  <pre><code>XStream xstream = new XStream();
  xstream.setMode(XStream.ID_REFERENCES);
  xstream.autodetectAnnotations(true);
  Writer writer = new FileWriter(xmlFile);        
  writer.write(xstream.toXML(myObject));
  writer.close();
  </code></pre>
  
  <p>=> serializing is OK but deserializing: <code>Exception in thread "main" com.thoughtworks.xstream.io.StreamException:  : only whitespace content allowed before start tag and not . (position: START_DOCUMENT seen .... @1:1)</code> </p>
  
  <p>if I do it like this:</p>
  
  <pre><code>XStream xstream = new XStream();
  xstream.setMode(XStream.NO_REFERENCES);
  xstream.autodetectAnnotations(true);
  Writer writer = new FileWriter(xmlFile);        
  writer.write(xstream.toXML(myObject));
  writer.close();
  </code></pre>
  
  <p>=> I got serialization problem: <code>Exception in thread "main" com.thoughtworks.xstream.io.StreamException:  : only whitespace content allowed before start tag and not . (position: START_DOCUMENT seen .... @1:1) 
      at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:78)
      at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:137)
      at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:130)
      at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:109)
      at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:94)
      at com.thoughtworks.xstream.io.xml.XppReader.&lt;init&gt;(XppReader.java:48)
      at com.thoughtworks.xstream.io.xml.XppDriver.createReader(XppDriver.java:44)
      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853)
      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:845)</code> </p>
  
  <p>With xml:</p>
  
  <pre><code>&lt;Test.Platform id="1"&gt;
      &lt;TaskImpl id="1"&gt;
            &lt;model reference="2"/&gt;
            &lt;name&gt;process&lt;/name&gt;
      &lt;/TaskImpl&gt;
  &lt;/Test.Platform id="1"&gt;
  </code></pre>
  
  <p>So Any suggestion?</p>
  
  <p>Thanks in advance.</p>