title: InstantiationException in web service client calling Web Service deployed to JBoss
body: <p>I'm deploying a StatelessSessionBean annotated with @WebService to JBoss. I'm taking the WSDL generated by JBoss to generate client stubs. My problem is in calling a method which returns a list of objects. If the list is empty the call succeeds however if the list is not empty then I get the following exception:</p>
  
  <pre><code>com.sun.xml.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException
   - with linked exception:         
  [javax.xml.bind.UnmarshalException: Unable to create an instance of com.companyname.api.ws.DataItemType                                                     
   - with linked exception:
  [java.lang.InstantiationException]]
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:124)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
      at $Proxy34.getWorkflows(Unknown Source)
      at com.companyname.api.SimpleClient.go(SimpleClient.java:48)
  </code></pre>
  
  <p>Searching the web led me to this discussion here: <a href="http://forums.java.net/jive/message.jspa?messageID=281780" rel="nofollow noreferrer">http://forums.java.net/jive/message.jspa?messageID=281780</a></p>
  
  <p>However I have set the @XmlSeeAlso stuff correctly and it is present on the generated stub classes. I can confirm that the DataItemType class <em>is</em> abstract so it is not surprising that an attempt to instantiate it causes a problem. I'm not at all clear on why the DataItemType class is being instantiated at all (as it is abstract). This is the XML that is returned from the server (it looks about right to me):</p>
  
  <pre><code>&lt;env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'&gt;
      &lt;env:Header&gt;&lt;/env:Header&gt;
      &lt;env:Body&gt;
          &lt;ns2:getWorkflowsResponse xmlns:ns2="http://ws.api.companyname.com/"&gt;
              &lt;return&gt;
                  &lt;id&gt;
                      &lt;identifier&gt;1&lt;/identifier&gt;
                      &lt;version&gt;0&lt;/version&gt;
                  &lt;/id&gt;
                  &lt;goal&gt;ENROLL&lt;/goal&gt;
                  &lt;dataItemType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="DataItemTypeText"&gt;
                      &lt;attributeName&gt;email&lt;/attributeName&gt;
                      &lt;displayName&gt;Email Address&lt;/displayName&gt;
                  &lt;/dataItemType&gt;
                  ...
              &lt;/return&gt;
          &lt;/ns2:getWorkflowsResponse&gt;
      &lt;/env:Body&gt;
  &lt;/env:Envelope&gt;
  </code></pre>
  
  <p>Does anyone know what I'm doing wrong?</p>