title: javax.xml.bind.UnmarshalException, Unable to create an instance of class
body: <p>I have the following situation: </p>
  
  <p>There is a tree structure for logical expressions which is used in our application and defined by a four class hierarchie:</p>
  
  <p><b>Node</b> is an abstract super class <br>
  <b>OrNode</b> is a sub class of Node representing OR <br>
  <b>AndNode</b> is a sub class of Node representing AND <br>
  <b>Leaf</b> is a sub class of Node representing a leaf node holding some data <br></p>
  
  <p>Now the tree structure should be transfered to a web service which will do some operation on the tree (e.g. evaluating the result by gathering some other information)</p>
  
  <p>The signature of that WS-Operation could be look like the following:</p>
  
  <pre><code>public TheResult evaluateTree(Node tree);
  </code></pre>
  
  <p>We are using JAX-WS and generate the web services classes with wsimport. First, there are no classes generated for OrNode, AndNode and Leaf. So, we added them manually. We convert the classes used on the client side to the generated classes created by wsimport. Next we want to call the web service operation with the converted tree as parameter. But here an exception occurs saying something like:</p>
  
  <pre><code>javax.xml.ws.soap.SOAPFaultException: javax.xml.bind.UnmarshalException - with linked exception: [javax.xml.bind.UnmarshalException: Unable to create an instance of InterfaceEntities.Node - with linked exception: [java.lang.InstantiationException]]
  </code></pre>
  
  <p>Here are the Wrapper classes added by us and generated classes:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "OrNode")
  public class OrNode
      extends Node
  {
  
  
  }
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "AndNode")
  public class AndNode
      extends Node
  {
  
  
  }
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "leaf")
  public class Leaf
      extends Node
  {
  
   ...
  }
  
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "node", propOrder = {
      "children",
      "resultSet",
  })
  @XmlSeeAlso({
      Leaf.class,
      OrNode.class,
      AndNode.class
  })
  public abstract class Node {
  
  ...
  }
  </code></pre>
  
  <p><b>EDIT:</b> <br>
  Here is the generated XML-File when using <code>Marshaller</code> as described in Blaise Doughan's blog (see answer below):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;ns2:treeInfo xmlns:ns2="http://webservice.api.process/"&gt;
      &lt;tree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:OrNode"&gt;
          &lt;children xsi:type="ns2:leaf"&gt;
              &lt;!-- some fields holding values --&gt;
          &lt;/children&gt;
          &lt;children xsi:type="ns2:leaf"&gt;
              &lt;!-- some fields holding values --&gt;
          &lt;/children&gt;
      &lt;/tree&gt;
      &lt;!-- some fields holding values --&gt;
  &lt;/ns2:treeInfo&gt;
  </code></pre>
  
  <p>It is a simple tree consisting of one orNode and two leaf nodes, 
  treeInfo represents the class holding the Node/tree object with some other information. It is marked as the XmlRootElement with the corresponding annotation.</p>
  
  <p>Did we miss anything?</p>
  
  <p>Thanks in advance!</p>