List of usage examples for java.lang.reflect InvocationTargetException getCause
public Throwable getCause()
From source file:org.jspresso.framework.util.accessor.bean.BeanCollectionAccessor.java
/** * {@inheritDoc}/*w ww . j av a 2 s .c o m*/ */ @Override public void removeFromValue(Object target, Object value) throws IllegalAccessException, InvocationTargetException { if (removerMethod == null) { removerMethod = MethodUtils.getMatchingAccessibleMethod(getBeanClass(), AccessorInfo.REMOVER_PREFIX + capitalizeFirst(getProperty()), new Class<?>[] { getElementClass() }); } try { removerMethod.invoke(getLastNestedTarget(target, getProperty()), value); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw ex; } catch (IllegalArgumentException | NoSuchMethodException ex) { throw new RuntimeException(ex); } }
From source file:org.xlcloud.openstack.client.RefreshAuthenticationHandler.java
/** * Invokes method (by reflection) and unwraps potential * {@link InvocationTargetException}// w ww. j a v a 2s. c om * * @param target * @param method * @param args * @return * @throws Throwable */ private Object doInvoke(Object target, Method method, Object[] args) throws Throwable { try { return method.invoke(target, args); } catch (InvocationTargetException e) { throw e.getCause(); } }
From source file:org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.java
public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault { Method method = null;/* w w w .j a v a 2s . c om*/ try { // get the implementation class for the Web Service Object obj = getTheImplementationObject(inMessage); Class ImplClass = obj.getClass(); AxisOperation op = inMessage.getOperationContext().getAxisOperation(); OMElement methodElement = inMessage.getEnvelope().getBody().getFirstElement(); AxisMessage inAxisMessage = op.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE); String messageNameSpace = null; String methodName = op.getName().getLocalPart(); Method[] methods = ImplClass.getMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].isBridge()) { continue; } if (methods[i].getName().equals(methodName)) { method = methods[i]; break; } } if (inAxisMessage != null) { RPCUtil.invokeServiceClass(inAxisMessage, method, obj, messageNameSpace, methodElement, inMessage); } replicateState(inMessage); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause != null) { String msg = cause.getMessage(); if (msg == null) { msg = "Exception occurred while trying to invoke service method " + method.getName(); } log.error(msg, cause); } else { cause = e; } throw AxisFault.makeFault(cause); } catch (Exception e) { String msg = "Exception occurred while trying to invoke service method " + method.getName(); log.error(msg, e); throw new AxisFault(msg, e); } }
From source file:org.gradle.internal.reflect.JavaMethod.java
public R invoke(T target, Object... args) { try {/* w w w . j a v a2 s .c o m*/ Object result = method.invoke(target, args); return returnType.cast(result); } catch (InvocationTargetException e) { throw UncheckedException.throwAsUncheckedException(e.getCause()); } catch (Exception e) { throw new GradleException(String.format("Could not call %s.%s() on %s", method.getDeclaringClass().getSimpleName(), method.getName(), target), e); } }
From source file:com.microsoft.tfs.util.proxy.LoggingInvocationHandler.java
@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { final long stTime = System.currentTimeMillis(); try {/*www . java 2 s . c o m*/ return method.invoke(proxiedObject, args); } catch (final InvocationTargetException ex) { throw ex.getCause(); } finally { final long elapsed = System.currentTimeMillis() - stTime; if (log.isTraceEnabled()) { traceLog(method, args, elapsed); } else if (log.isDebugEnabled()) { debugLog(method, elapsed); } } }
From source file:org.pentaho.di.ui.core.dialog.DisplayInvocationHandler.java
@Override public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { if (display.getThread() == Thread.currentThread()) { try {/*from w ww. j a va 2s . c o m*/ return method.invoke(delegate, args); } catch (InvocationTargetException e) { throw e.getCause(); } } if (asyncForVoid && method.getReturnType().equals(Void.TYPE)) { display.asyncExec(new Runnable() { @Override public void run() { try { method.invoke(delegate, args); } catch (Throwable e) { if (e instanceof InvocationTargetException) { e = e.getCause(); } log.logError(e.getMessage(), e); } } }); return null; } final ResultHolder resultHolder = new ResultHolder(); display.syncExec(new Runnable() { @Override public void run() { try { resultHolder.result = method.invoke(delegate, args); } catch (InvocationTargetException e) { resultHolder.throwable = e.getCause(); } catch (Exception e) { resultHolder.throwable = e; } } }); if (resultHolder.result != null) { return resultHolder.result; } else { throw resultHolder.throwable; } }
From source file:grails.plugin.cloudfoundry.GrailsHttpRequestFactory.java
protected HttpURLConnection wrap(final HttpURLConnection connection) { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(HttpURLConnection.class); enhancer.setInterceptDuringConstruction(false); Callback callback = new MethodInterceptor() { @SuppressWarnings("hiding") public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { try { Object value = method.invoke(connection, args); if ("getInputStream".equals(method.getName())) { return wrap((InputStream) value); }// w w w . j av a 2 s.c om return value; } catch (InvocationTargetException ex) { throw ex.getCause(); } } }; enhancer.setCallbacks(new Callback[] { callback }); enhancer.setCallbackTypes(new Class[] { callback.getClass() }); return (HttpURLConnection) enhancer.create(new Class[] { URL.class }, new Object[] { connection.getURL() }); }
From source file:org.wso2.carbon.analytics.spark.core.udf.adaptor.UDF0Adaptor.java
@Override public Object call(Object o) throws Exception { ;/* w ww .j a v a 2 s .c o m*/ Method udfMethod = udfClass.getDeclaredMethod(udfMethodName, parameterTypes); try { if (Modifier.isStatic(udfMethod.getModifiers())) { return udfMethod.invoke(null); } else { Object udfInstance = udfClass.newInstance(); return udfMethod.invoke(udfInstance); } } catch (InvocationTargetException e) { log.error("Error while invoking method: " + udfMethodName + ", " + e.getMessage(), e.getCause()); throw new Exception("Error while invoking method: " + udfMethodName + ", " + e.getMessage(), e.getCause()); } }
From source file:be.fgov.kszbcss.rhq.websphere.connector.FailFastInvocationHandler.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (lastConnectorNotAvailableException != -1 && System.currentTimeMillis() - lastConnectorNotAvailableException > 120000) { log.debug("Resetting lastConnectorNotAvailableException"); lastConnectorNotAvailableException = -1; }//from w w w .j av a 2 s .co m if (lastConnectorNotAvailableException == -1) { try { return method.invoke(target, args); } catch (InvocationTargetException invocationTargetException) { Throwable exception = invocationTargetException.getCause(); Throwable t = exception; do { if (log.isDebugEnabled()) { log.debug("cause = " + t.getClass().getName()); } if (t instanceof ConnectorNotAvailableException) { lastConnectorNotAvailableException = System.currentTimeMillis(); break; } t = t.getCause(); } while (t != null); if (log.isDebugEnabled()) { if (lastConnectorNotAvailableException == -1) { log.debug("Not setting lastConnectorNotAvailableException"); } else { log.debug("Setting lastConnectorNotAvailableException"); } } throw exception; } } else { throw new ConnectorNotAvailableException( "The connector has been temporarily marked as unavailable because of a previous ConnectorNotAvailableException"); } }
From source file:org.wso2.carbon.analytics.spark.core.udf.adaptor.UDF1Adaptor.java
@Override public Object call(Object o) throws Exception { Method udfMethod = udfClass.getDeclaredMethod(udfMethodName, parameterTypes); try {/*from ww w .ja v a 2 s . c o m*/ if (Modifier.isStatic(udfMethod.getModifiers())) { return udfMethod.invoke(null, o); } else { Object udfInstance = udfClass.newInstance(); return udfMethod.invoke(udfInstance, o); } } catch (InvocationTargetException e) { log.error("Error while invoking method: " + udfMethodName + ", " + e.getMessage(), e.getCause()); throw new Exception("Error while invoking method: " + udfMethodName + ", " + e.getMessage(), e.getCause()); } }