List of usage examples for java.lang.reflect UndeclaredThrowableException getCause
public synchronized Throwable getCause()
From source file:org.apache.servicemix.camel.nmr.ws.addressing.WSAddressingTest.java
public void testImplicitMAPs() throws Exception { try {/* ww w.j av a 2s . co m*/ String greeting = greeter.greetMe("implicit1"); assertEquals("unexpected response received from service", "Hello implicit1", greeting); checkVerification(); greeting = greeter.greetMe("implicit2"); assertEquals("unexpected response received from service", "Hello implicit2", greeting); checkVerification(); } catch (UndeclaredThrowableException ex) { throw (Exception) ex.getCause(); } }
From source file:org.apache.servicemix.camel.nmr.ws.addressing.WSAddressingTest.java
public void testVersioning() throws Exception { try {//from w w w . j av a2s . co m // expect two MAPs instances versioned with 200408, i.e. for both // the partial and full responses mapVerifier.expectedExposedAs.add(VersionTransformer.Names200408.WSA_NAMESPACE_NAME); mapVerifier.expectedExposedAs.add(VersionTransformer.Names200408.WSA_NAMESPACE_NAME); String greeting = greeter.greetMe("versioning1"); assertEquals("unexpected response received from service", "Hello versioning1", greeting); checkVerification(); greeting = greeter.greetMe("versioning2"); assertEquals("unexpected response received from service", "Hello versioning2", greeting); checkVerification(); } catch (UndeclaredThrowableException ex) { throw (Exception) ex.getCause(); } }
From source file:org.apache.servicemix.camel.nmr.ws.addressing.WSAddressingTest.java
public void testApplicationFault() throws Exception { try {//from w w w . ja v a2 s .com greeter.testDocLitFault("BadRecordLitFault"); fail("expected fault from service"); } catch (BadRecordLitFault brlf) { checkVerification(); } catch (UndeclaredThrowableException ex) { throw (Exception) ex.getCause(); } String greeting = greeter.greetMe("intra-fault"); assertEquals("unexpected response received from service", "Hello intra-fault", greeting); try { greeter.testDocLitFault("NoSuchCodeLitFault"); fail("expected NoSuchCodeLitFault"); } catch (NoSuchCodeLitFault nsclf) { checkVerification(); } catch (UndeclaredThrowableException ex) { throw (Exception) ex.getCause(); } }
From source file:com.amazon.carbonado.repo.indexed.ManagedIndex.java
private Storable makeIndexEntry(S userStorable) throws PersistException { try {//from w w w . java 2 s . co m Storable indexEntry = mIndexEntryStorage.prepare(); mAccessor.copyFromMaster(indexEntry, userStorable); return indexEntry; } catch (UndeclaredThrowableException e) { Throwable cause = e.getCause(); if (cause instanceof PersistException) { throw (PersistException) cause; } throw new PersistException(cause); } catch (Exception e) { if (e instanceof PersistException) { throw (PersistException) e; } throw new PersistException(e); } }
From source file:com.alibaba.jstorm.yarn.appmaster.JstormMaster.java
void startTimelineClient(final Configuration conf) throws YarnException, IOException, InterruptedException { try {//from w ww.j a v a 2 s .c o m appSubmitterUgi.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) { // Creating the Timeline Client timelineClient = TimelineClient.createTimelineClient(); timelineClient.init(conf); timelineClient.start(); } else { timelineClient = null; LOG.warn("Timeline service is not enabled"); } return null; } }); } catch (UndeclaredThrowableException e) { throw new YarnException(e.getCause()); } }
From source file:com.abiquo.abiserver.commands.stub.AbstractAPIStub.java
protected void populateErrors(final Exception ex, final BasicResult result, final String methodName, final String message) { if (ex instanceof AuthorizationException) { populateErrors((AuthorizationException) ex, result, methodName, message); } else if (ex instanceof AbiquoException) { populateErrors((AbiquoException) ex, result, methodName, message); } else if (ex instanceof UserSessionException) { throw (UserSessionException) ex; } else if (ex instanceof UndeclaredThrowableException) { UndeclaredThrowableException undeclared = (UndeclaredThrowableException) ex; if (undeclared.getCause() instanceof TimeoutException) { result.setSuccess(false);//from w ww. ja v a 2 s . c o m result.setMessage("Connection timed out during '" + methodName + "' invocation"); } } else { result.setSuccess(false); result.setMessage(ex.getMessage()); } }
From source file:no.sesat.search.mode.command.AbstractSearchCommand.java
/** * Called by thread executor/* w w w.jav a 2 s .c om*/ * * @return */ @Override public ResultList<ResultItem> call() { MDC.put(Site.NAME_KEY, datamodel.getSite().getSite().getName()); MDC.put("UNIQUE_ID", datamodel.getParameters().getUniqueId()); thread = Thread.currentThread(); final String t = thread.getName(); final String statName = getSearchConfiguration().getStatisticalName(); if (statName != null && statName.length() > 0) { Thread.currentThread().setName(t + " [" + getSearchConfiguration().getStatisticalName() + ']'); } else { Thread.currentThread().setName(t + " [" + getClass().getSimpleName() + ']'); } try { try { LOG.trace("call()"); performQueryTransformation(); checkForCancellation(); final ResultList<ResultItem> result = performExecution(); checkForCancellation(); performResultHandling(result); checkForCancellation(); completed = true; thread = null; return result; } catch (UndeclaredThrowableException ute) { if (ute.getCause() instanceof DataModelAccessException && isCancelled()) { // This is partially expected because the datamodel's // controlLevel would have moved on through the process stack. LOG.trace("Cancelled command threw underlying exception", ute.getCause()); return new BasicResultList<ResultItem>(); } throw ute; } } catch (RuntimeException rte) { LOG.error(ERROR_RUNTIME, rte); return new BasicResultList<ResultItem>(); } finally { // restore thread name Thread.currentThread().setName(t); } }
From source file:org.apache.activemq.bugs.AMQ7067Test.java
@Test public void testRollback() throws Exception { final Connection connection = ACTIVE_MQ_NON_XA_CONNECTION_FACTORY.createConnection(); connection.start();//from ww w .j a v a 2 s . co m Session session = connection.createSession(true, Session.SESSION_TRANSACTED); Queue holdKahaDb = session.createQueue("holdKahaDb"); MessageProducer holdKahaDbProducer = session.createProducer(holdKahaDb); TextMessage helloMessage = session.createTextMessage(StringUtils.repeat("a", 10)); holdKahaDbProducer.send(helloMessage); Queue queue = session.createQueue("test"); produce(connection, queue, 100, 512 * 1024); session.rollback(); produce(connection, queue, 100, 512 * 1024); System.out.println(String.format("QueueSize %s: %d", holdKahaDb.getQueueName(), getQueueSize(holdKahaDb.getQueueName()))); purgeQueue(queue.getQueueName()); Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { return 0 == getQueueSize(queue.getQueueName()); } }); // force gc broker.getPersistenceAdapter().checkpoint(true); connection.close(); curruptIndexFile(getDataDirectory()); broker.stop(); broker.waitUntilStopped(); createBroker(); broker.waitUntilStarted(); // no sign of the test queue on recovery, rollback is the default for any inflight // this test serves as a sanity check on existing behaviour try { getQueueSize(holdKahaDb.getQueueName()); fail("expect InstanceNotFoundException"); } catch (UndeclaredThrowableException expected) { assertTrue(expected.getCause() instanceof InstanceNotFoundException); } }
From source file:org.apache.ambari.view.slider.SliderAppsViewControllerImpl.java
private <T> T invokeSliderClientRunnable(final SliderClientContextRunnable<T> runnable) throws IOException, InterruptedException, YarnException { ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); try {// w ww .jav a 2 s . c o m boolean securityEnabled = Boolean.valueOf(getHadoopConfigs().get("security_enabled")); UserGroupInformation.setConfiguration(getSliderClientConfiguration()); UserGroupInformation sliderUser; String loggedInUser = getUserToRunAs(); if (securityEnabled) { String viewPrincipal = getViewParameterValue(PARAM_VIEW_PRINCIPAL); String viewPrincipalKeytab = getViewParameterValue(PARAM_VIEW_PRINCIPAL_KEYTAB); UserGroupInformation ambariUser = UserGroupInformation .loginUserFromKeytabAndReturnUGI(viewPrincipal, viewPrincipalKeytab); if (loggedInUser.equals(ambariUser.getShortUserName())) { // HDFS throws exception when caller tries to impresonate themselves. // User: admin@EXAMPLE.COM is not allowed to impersonate admin sliderUser = ambariUser; } else { sliderUser = UserGroupInformation.createProxyUser(loggedInUser, ambariUser); } } else { sliderUser = UserGroupInformation.getBestUGI(null, loggedInUser); } try { T value = sliderUser.doAs(new PrivilegedExceptionAction<T>() { @Override public T run() throws Exception { final SliderClient sliderClient = createSliderClient(); try { return runnable.run(sliderClient); } finally { destroySliderClient(sliderClient); } } }); return value; } catch (UndeclaredThrowableException e) { Throwable cause = e.getCause(); if (cause instanceof YarnException) { YarnException ye = (YarnException) cause; throw ye; } throw e; } } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } }
From source file:org.apache.hadoop.hive.metastore.RawStoreProxy.java
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try {/* w ww .java 2 s. c o m*/ Deadline.registerIfNot(socketTimeout); boolean isTimerStarted = Deadline.startTimer(method.getName()); try { return method.invoke(base, args); } finally { if (isTimerStarted) { Deadline.stopTimer(); } } } catch (UndeclaredThrowableException e) { throw e.getCause(); } catch (InvocationTargetException e) { throw e.getCause(); } }