/** * Give a target Throwable, set the initialCause Throwable as the initial cause on the target. * @param target The throwable on which to set the initial cause * @param initialCause The initial cause to set on the target Throwable. */ public static void setInitialCause(Throwable target, Throwable initialCause) { if (target != null && initialCause != null) { // Create a WebServiceException from the initialCause throwable. This skips over things like // AxisFault as a cause. Set the result on the target throwable. try { WebServiceException localException = ExceptionFactory.makeWebServiceException(initialCause); target.initCause(localException.getCause()); } catch (Throwable t) { // If the cause had already been set, then it can't be set again; it throws an exception. if (log.isDebugEnabled()) { log.debug("Caught exception trying to set initial cause on: " + target +". Initial cause: " + initialCause + ". Caught: " + t); } } } } }
/** * Give a target Throwable, set the initialCause Throwable as the initial cause on the target. * @param target The throwable on which to set the initial cause * @param initialCause The initial cause to set on the target Throwable. */ public static void setInitialCause(Throwable target, Throwable initialCause) { if (target != null && initialCause != null) { // Create a WebServiceException from the initialCause throwable. This skips over things like // AxisFault as a cause. Set the result on the target throwable. try { WebServiceException localException = ExceptionFactory.makeWebServiceException(initialCause); target.initCause(localException.getCause()); } catch (Throwable t) { // If the cause had already been set, then it can't be set again; it throws an exception. if (log.isDebugEnabled()) { log.debug("Caught exception trying to set initial cause on: " + target +". Initial cause: " + initialCause + ". Caught: " + t); } } } } }
public Object invokeWithRetry(Method method, Object[] args) throws IllegalAccessException, InvocationTargetException { List<Throwable> exceptions = new ArrayList<>(); for (int i = 0; i < retriesForConnectionFailures + 1; i++) { try { return method.invoke(winrm, args); } catch (InvocationTargetException targetException) { Throwable e = targetException.getTargetException(); if (e instanceof SOAPFaultException) { throw (SOAPFaultException)e; } else if (e instanceof WebServiceException) { WebServiceException wsException = (WebServiceException) e; if (!(wsException.getCause() instanceof IOException)) { throw new RuntimeException("Exception occurred while making winrm call", wsException); } LOG.debug("Ignoring exception and retrying (attempt " + (i + 1) + " of " + (retriesForConnectionFailures + 1) + ") {}", wsException); try { Thread.sleep(5 * 1000); } catch (InterruptedException interruptedException) { Thread.currentThread().interrupt(); throw new RuntimeException("Exception occured while making winrm call", e.initCause(wsException)); } exceptions.add(wsException); } else { throw new IllegalStateException("Failure when calling " + method + args, e); } } } throw new RuntimeException("failed task " + method.getName(), exceptions.get(0)); }
if (e.getCause() instanceof SocketTimeoutException) { if (retry > retries) { throw new ServiceUnavailableException(e); if (e.getTargetException() instanceof WebServiceException && !(e.getTargetException() instanceof SOAPFaultException)) { WebServiceException wse = (WebServiceException) e.getTargetException(); if (wse.getCause() instanceof SocketTimeoutException) { if (retry >= retries) { throw new ServiceUnavailableException(e); monitor.serviceUnavailableRetry(wse.getCause()); ++retry; } else {
if (e.getCause() instanceof SocketTimeoutException) { if (retry > retries) { throw new ServiceUnavailableException(e); if (e.getTargetException() instanceof WebServiceException && !(e.getTargetException() instanceof SOAPFaultException)) { WebServiceException wse = (WebServiceException) e.getTargetException(); if (wse.getCause() instanceof SocketTimeoutException) { if (retry >= retries) { throw new ServiceUnavailableException(e); monitor.serviceUnavailableRetry(wse.getCause()); ++retry; } else {
rspStatus = convertStatus(messages, result); } catch (final WebServiceException se) { if (se.getCause() instanceof IOException) { rspStatus = fillStatus(messages, MessageDeliveryStatus.IN_DOUBT, StatusCodeEnum.ERR_NETWORK, se.getCause().getMessage()); } else { rspStatus = fillStatus(messages, MessageDeliveryStatus.IN_DOUBT, StatusCodeEnum.ERR_GENERIC, se.getCause().getMessage());
@Test public void testTimeout() throws Exception { System.getProperties().remove("com.sun.CORBA.POA.ORBServerId"); System.getProperties().remove("com.sun.CORBA.POA.ORBPersistentServerPort"); System.setProperty("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB"); System.setProperty("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton"); System.setProperty("jacorb.connection.client.pending_reply_timeout", "1000"); URL wsdlUrl = this.getClass().getResource("/wsdl_systest/hello_world_corba_timeout.wsdl"); new SpringBusFactory().createBus("org/apache/cxf/systest/corba/hello_world_client.xml"); GreeterCORBAService gcs = new GreeterCORBAService(wsdlUrl, SERVICE_NAME); Greeter port = gcs.getPort(new QName("http://cxf.apache.org/hello_world_corba", "GreeterTimeoutCORBAPort"), GreeterCORBAService.GreeterProxy.class); try { port.greetMe("Betty"); fail("Should throw org.omg.CORBA.TIMEOUT exception"); } catch (WebServiceException e) { assertTrue(e.getCause() instanceof TIMEOUT); } finally { System.getProperties().remove("org.omg.CORBA.ORBClass"); System.getProperties().remove("org.omg.CORBA.ORBSingletonClass"); System.setProperty("org.omg.CORBA.ORBClass", "com.sun.corba.se.impl.orb.ORBImpl"); } }
.getCause(); if (mue == null || mue.getMessage() == null) { throw expected;
@Test public void testFaultStackTrace() throws Exception { System.setProperty("cxf.config.file.url", getClass().getResource("fault-stack-trace.xml").toString()); URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service = new SOAPService(wsdl, serviceName); ExecutorService ex = Executors.newFixedThreadPool(1); service.setExecutor(ex); assertNotNull(service); Greeter greeter = service.getPort(portName, Greeter.class); updateAddressPort(greeter, PORT); try { // trigger runtime exception throw of implementor method greeter.testDocLitFault(""); fail("Should have thrown Runtime exception"); } catch (WebServiceException e) { assertEquals("can't get back original message", "Unknown source", e.getCause().getMessage()); assertTrue(e.getCause().getStackTrace().length > 0); } }
.getCause(); if (mue == null || mue.getMessage() == null) { throw expected;
Throwable cause = wex.getCause(); if (cause != null) { objectCtx.setException(cause);
fail("Did not receive expected PolicyException."); } catch (WebServiceException wex) { PolicyException ex = (PolicyException)wex.getCause(); assertEquals("INCOMPATIBLE_HTTPCLIENTPOLICY_ASSERTIONS", ex.getCode());
fail("Did not receive expected Exception."); } catch (WebServiceException wse) { SoapFault sf = (SoapFault)wse.getCause(); assertEquals("Server", sf.getFaultCode().getLocalPart());
fail("Twoway operation unexpectedly succeded."); } catch (WebServiceException ex) { Throwable cause = ex.getCause(); SoapFault sf = (SoapFault)cause; fail("Expected PingMeFault not thrown."); } catch (WebServiceException ex) { Throwable cause = ex.getCause(); SoapFault sf = (SoapFault)cause; assertEquals(expectedMsg, sf.getReason());