title: XML parsing using xstream
body: <p>I have the following XML structure that I am parsing into the classes mentioned below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
  &lt;OrderDiscount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;Status&gt;Failed&lt;/Status&gt;
    &lt;Errors&gt;Error : Customer 00000037 not found : Product 51 D0003 not found&lt;/Errors&gt;
    &lt;DeliveryID&gt;00000037&lt;/DeliveryID&gt;
    &lt;CarriageAmount&gt;0&lt;/CarriageAmount&gt;
    &lt;TotalDiscount&gt;0&lt;/TotalDiscount&gt;
    &lt;OrderLines&gt;
      &lt;Warehouse&gt;51&lt;/Warehouse&gt;
      &lt;Product&gt;D0003&lt;/Product&gt;
      &lt;ContractPrice&gt;N&lt;/ContractPrice&gt;
      &lt;UnitOfSale&gt;20&lt;/UnitOfSale&gt;
      &lt;Ordered&gt;1&lt;/Ordered&gt;
      &lt;ListPrice&gt;10&lt;/ListPrice&gt;
      &lt;NetPrice&gt;10&lt;/NetPrice&gt;
      &lt;NewNetPrice&gt;0&lt;/NewNetPrice&gt;
    &lt;/OrderLines&gt;
  &lt;/OrderDiscount&gt;
  </code></pre>
  
  <p>Here, we can have multiple instances of <code>&lt;OrderLines&gt;</code>. I am trying to parse it using the following 2 classes</p>
  
  <pre><code>import java.util.List;
  import com.thoughtworks.xstream.annotations.XStreamAlias;
  
  /**
   * @author nka
   *
   */
  
  @XStreamAlias("OrderDiscount")
  public class OrderDiscount {
  
  
      @XStreamAlias("Status")
      private String Status;
  
      @XStreamAlias("Errors")
      private String Errors;
  
      @XStreamAlias("DeliveryID")
      private String DeliveryID;
  
      @XStreamAlias("CarriageAmount")
      private String CarriageAmount;
  
      @XStreamAlias("TotalDiscount")
      private String TotalDiscount;
  
      @XStreamAlias("OrderLines")
      private List&lt;OrderLines&gt; OrderLines;
  
  }
  </code></pre>
  
  <p>2nd Class:</p>
  
  <pre><code>public class OrderLines {
  
      @XStreamAlias("Warehouse")
      private String Warehouse;
  
      @XStreamAlias("Product")
      private String Product;
  
      @XStreamAlias("ContractPrice")
      private String ContractPrice;
  
      @XStreamAlias("UnitOfSale")
      private String UnitOfSale;
  
      @XStreamAlias("Ordered")
      private String Ordered;
  
      @XStreamAlias("ListPrice")
      private String ListPrice;
  
      @XStreamAlias("NetPrice")
      private String NetPrice;
  
      @XStreamAlias("NewNetPrice")
      private String NewNetPrice;
  }
  </code></pre>
  
  <p>I am using the following code to parse it:</p>
  
  <pre><code>    OrderDiscount orderDiscount = null;
  
      final XStream xstream = new XStream(new StaxDriver());
      xstream.processAnnotations(OrderDiscount.class);
      xstream.processAnnotations(OrderLines.class);
  
      orderDiscount = (OrderDiscount) xstream.fromXML(response);
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>Target exception: com.thoughtworks.xstream.converters.ConversionException: Warehouse : Warehouse : Warehouse : Warehouse
  ---- Debugging information ----
  message             : Warehouse : Warehouse
  cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
  cause-message       : Warehouse : Warehouse
  class               : uk.co.portaltech.quicklive.thirdparty.datel.OrderDiscount
  required-type       : java.util.ArrayList
  path                : /OrderDiscount/OrderLines/Warehouse
  line number         : 1
  -------------------------------
  </code></pre>
  
  <p>Can someone please help me to correct the structure of my Java OBJECTS to resolve this?</p>