title: Web Service throwing exception using Axis2 Java
body: <p>I'm actually developing a Web Service in Java using Axis 2.
  I designed my service as a POJO (Plain Old Java Object) with public method throwing exceptions :</p>
  
  <pre><code>public class MyService {
     public Object myMethod() throws MyException {
          [...]
     }
  }
  </code></pre>
  
  <p>I then generated the WSDL using Axis2 ant task. With the WSDL I generate a client stub to test my service. The generated code contains a "MyExceptionException" and the "myMethod" in the stub declare to throw this :</p>
  
  <pre><code>public class MyServiceStub extends org.apache.axis2.client.Stub {
      [...]
      public MyServiceStub.MyMethodResponse myMethod(MyServiceStub.MyMethod myMethod)
      throws java.rmi.RemoteException, MyExceptionException0 {
          [...]
      }
      [...]
  }
  </code></pre>
  
  <p>But when calling the method surrounded by a catch, the "MyExceptionException" is never transmitted by the server which transmit an AxisFault instead (subclass of RemoteException).</p>
  
  <p>I assume the problem is server-side but don't find where. The service is deployed as an aar file in the axis2 webapp on a tomcat 5.5 server. The services.xml looks like this :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;service name="MyService" scope="application"&gt;
      &lt;description&gt;&lt;/description&gt;
      &lt;messageReceivers&gt;
          &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" 
              class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/&gt;
          &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
             class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/&gt;
      &lt;/messageReceivers&gt;
      &lt;parameter name="ServiceClass"&gt;MyService&lt;/parameter&gt;
      &lt;parameter name="ServiceTCCL"&gt;composite&lt;/parameter&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p>If the behavior is normal then I'll drop the use of Exceptions (which is not vital to my project) but I'm circumspect why Java2WSDL generate custom &lt;wsdl:fault&gt; in operation input &amp; output declaration and WSDL2Java generate an Exception class (and declare to throw it in the stub method) if this is not usable...</p>