users@glassfish.java.net

How to throw a SOAPFaultException from an EJB

From: Vincent Deschênes <vdeschenes_at_stelvio.com>
Date: Tue, 23 Mar 2010 16:53:01 -0400

I am trying to throw a SOAPFaultException from a web service implemented on an EJB.

 

If I simply throw new SOAPFaultException(…)

 

I get this SoapFault

 

      <S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">

         <faultcode>S:Server</faultcode>

         <faultstring>javax.ejb.EJBException</faultstring>

      </S:Fault>

 

Which describe an javax.ejb.EJBException which is caused by me throwing my SOAPFaultException. I can see it if I enable the
stacktrace in the exception.

If I disable the stack trace I always get this EJBException and I have no way to set an error message.

 

Anyone has a solution ?

 

I am using glassfish V3.

 

Thanks.

 

Vincent Deschenes