title: Is it possible to handle User Defined Exception using JAX WS Dispatch API?
body: <p>I'm performing dynamic webservices call using following code snippet:</p>
  
  <pre><code>    JAXBContext jc = getJAXBContext(requestClass, responseClass, jaxbContextExtraClasses);
      Dispatch&lt;Object&gt; dispatch = service.createDispatch(portQName, jc, Service.Mode.PAYLOAD);
  
      Object requestValue = getRequestValue(requestClass, pOrderedParameters);
      JAXBElement&lt;?&gt; request =
              new JAXBElement(new QName(serviceQNameStr, pOperationName), requestValue.getClass(), null, requestValue);
      Object tmpResponse = dispatch.invoke(request);
  </code></pre>
  
  <p>Invocation works perfectly, except if I add a user defined exception on the service (a basic UserException extends java.lang.Exception).</p>
  
  <p>First I get:</p>
  
  <blockquote>
    <p>javax.xml.bind.UnmarshalException:
    unexpected element
    (uri:"<a href="http://schemas.xmlsoap.org/soap/envelope/" rel="nofollow noreferrer">http://schemas.xmlsoap.org/soap/envelope/</a>",
    local:"Fault"). Expected elements are
    &lt;{<a href="http://my.namespace/" rel="nofollow noreferrer">http://my.namespace/</a>}myMethod>,&lt;{<a href="http://my.namespace/" rel="nofollow noreferrer">http://my.namespace/</a>}myResponse></p>
  </blockquote>
  
  <p>Then I added the UserException_Exception JAX-WS generated type to my JAXB Context, and then get:</p>
  
  <blockquote>
    <p>Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
     this problem is related to the following location:
      at java.lang.StackTraceElement
      at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
      at java.lang.Throwable
      at java.lang.Exception</p>
  </blockquote>
  
  <p>Only solution available I found are:</p>
  
  <ul>
  <li>dispatch directly a Soap message and handle Soap fault directly (this is the way Jboss JAX-WS implementation performs a standard JAX-WS call using services interfaces). This is not an available solution for me, I want to use a high level implementation (the more I get close to Soap message the less dynamic my code can be)</li>
  <li>usage of JAXBRIContext.ANNOTATION_READER, which is implementation specific and not an available solution for me, in order to annotate annotates java.lang.Exception as @XmlTransient</li>
  </ul>
  
  <p>The service with a user defined exception performs well using the JAX-WS generated standard client stubs and using a tool such Soap UI. Problem occurs in deserialization of the message when I have no user defined exception artifact in the JAXB context, and during invocation when I add those non JAXB compatible artifacts in the JAXB context.</p>
  
  <p>I'm usign Jboss WS webservice stack within Jboss 4.2.3.GA</p>
  
  <p>Any elegant solution to this problem is welcomed !</p>