UndeclaredThrowableException
cbax007 Feb 13, 2006 2:17 PMI have a Java Service Endpoint that throws a custom Exception called FinderException (not javax.ejb.FinderException). The method on the Interface that the SE implements is as follows:
Itinerary findItinerary(Long itineraryId) throws FinderException;
The code for that custom exception class is as follows:
public class FinderException extends java.rmi.RemoteException { public FinderException(String s, Throwable cause) { super(s, cause); } public FinderException(String s) { super(s); } }
In the SE implementation class, I throw that custom exception in cases when I can not find a matching result in the DB for the supplied itineraryId. On the client side, I'm using Dynamic Proxies to execute the web service call. Now, when I make the call to findItinerary for an itineraryId that does not exist, I'm expecting that on the client side, I will be able to catch that FinderException and handle it appropriately. Unfortunately, what I get instead is an UndeclaredThrowableException which renders my try:catch useless. The stack trace I get is as follows:
java.lang.reflect.UndeclaredThrowableException at $Proxy1.findItinerary(Unknown Source) at com.ati.client.ItineraryInfoTest.main(ItineraryInfoTest.java:13) Caused by: org.jboss.axis.AxisFault: Unable to find Itinerary with id=1 at org.jboss.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:303) at org.jboss.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:142) at org.jboss.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1249) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:375) at org.jboss.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:257) at org.jboss.axis.MessagePart.getAsSOAPEnvelope(MessagePart.java:684) at org.jboss.axis.Message.getSOAPEnvelope(Message.java:428) at org.jboss.axis.client.Call.invokeEngine(Call.java:3102) at org.jboss.axis.client.Call.invoke(Call.java:3064) at org.jboss.axis.client.Call.invoke(Call.java:2652) at org.jboss.axis.client.Call.invoke(Call.java:2561) at org.jboss.axis.client.Call.invokeInternal(Call.java:1982) at org.jboss.axis.client.Call.invoke(Call.java:1920) at org.jboss.webservice.client.CallImpl.invoke(CallImpl.java:265) at org.jboss.axis.client.AxisClientProxy.invokeSEIMethod(AxisClientProxy.java:286) at org.jboss.webservice.client.PortProxy.invoke(PortProxy.java:177) ... 2 more
Can anyone help me to figure out if this is expected behavior and if not, what can I do to fix it?