Example usage for java.lang.reflect InvocationTargetException getCause

List of usage examples for java.lang.reflect InvocationTargetException getCause

Introduction

In this page you can find the example usage for java.lang.reflect InvocationTargetException getCause.

Prototype

public Throwable getCause() 

Source Link

Document

Returns the cause of this exception (the thrown target exception, which may be null ).

Usage

From source file:org.jspresso.framework.util.accessor.bean.BeanListAccessor.java

/**
 * {@inheritDoc}// ww w.  j a v a 2 s  .  c o  m
 */
@Override
public void addToValue(Object target, int index, Object value)
        throws IllegalAccessException, InvocationTargetException {
    if (adderAtMethod == null) {
        adderAtMethod = MethodUtils.getMatchingAccessibleMethod(getBeanClass(),
                AccessorInfo.ADDER_PREFIX + capitalizeFirst(getProperty()),
                new Class<?>[] { Integer.TYPE, getElementClass() });
    }
    try {
        adderAtMethod.invoke(getLastNestedTarget(target, getProperty()), index, 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.apache.hadoop.io.retry.RetryInvocationHandler.java

private Object invokeMethod(Method method, Object[] args) throws Throwable {
    try {/*ww  w  .ja  va  2  s  .c om*/
        if (!method.isAccessible()) {
            method.setAccessible(true);
        }
        return method.invoke(implementation, args);
    } catch (InvocationTargetException e) {
        throw e.getCause();
    }
}

From source file:com.espertech.esper.epl.script.ExprNodeScriptEvalMVEL.java

public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) {
    Map<String, Object> paramsList = new HashMap<String, Object>();
    for (int i = 0; i < names.length; i++) {
        paramsList.put(names[i], parameters[i].evaluate(eventsPerStream, isNewData, context));
    }/*from www  .  j  a  v  a  2s  . c  om*/
    paramsList.put(ExprNodeScript.CONTEXT_BINDING_NAME, context.getAgentInstanceScriptContext());

    try {
        Object result = MVELInvoker.executeExpression(executable, paramsList);

        if (coercer != null) {
            return coercer.coerceBoxed((Number) result);
        }

        return result;
    } catch (InvocationTargetException ex) {
        Throwable mvelException = ex.getCause();
        String message = "Unexpected exception executing script '" + scriptName + "' for statement '"
                + statementName + "' : " + mvelException.getMessage();
        log.error(message, mvelException);
        throw new EPException(message, ex);
    }
}

From source file:org.fcrepo.kernel.impl.LockReleasingSession.java

private Object delegate(final Method method, final Object[] args) throws Throwable {
    final Object invocationResult;
    try {/*  www  .j  a  v  a 2 s  .c  o m*/
        invocationResult = method.invoke(session, args);
    } catch (final InvocationTargetException e) {
        throw e.getCause();
    }
    return invocationResult;
}

From source file:net.sourceforge.fenixedu.util.domain.SlotSelector.java

private RuntimeException handleInvocationTargetException(InvocationTargetException e, String message) {
    if (e.getCause() instanceof WriteOnReadError) {
        throw (WriteOnReadError) e.getCause();
    }//from   w w w . j a v a  2  s . c  om
    if (e.getCause() instanceof RuntimeException) {
        return (RuntimeException) e.getCause();
    } else {
        return new DomainException(message, e.getCause());
    }
}

From source file:com.useekm.types.GeometryMarshall.java

@Override
public T deserialize(Literal literal) {
    try {/* w w  w. j  av  a 2  s . c  o m*/
        return constructor.newInstance(literal.stringValue());
    } catch (InvocationTargetException e) {
        throw new IllegalStateException(e.getCause());
    } catch (InstantiationException e) {
        throw new IllegalStateException(e);
    } catch (IllegalAccessException e) {
        throw new IllegalStateException(e);
    }
}

From source file:com.eincs.decanter.container.simple.route.SimpleRouteService.java

@Override
public void doServe(DecanterRequest request, DecanterResponse response) throws Exception {
    try {//w ww  .jav  a 2s  .  c  o  m
        method.invoke(target, new Object[] { request, response });
    } catch (InvocationTargetException e) {
        Throwable t = e.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw e;
        }
    }
}

From source file:com.anrisoftware.prefdialog.dialogaction.AbstractDialogActionLogger.java

DialogActionException errorCreateDialog(AbstractDialogAction<?, ?> action, InvocationTargetException e) {
    Throwable cause = e.getCause();
    return logException(new DialogActionException(error_create_dialog, cause).add(action, action),
            error_create_dialog_message, cause.getLocalizedMessage());
}

From source file:therian.cdi.internal.MapperHandler.java

@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
    if (Object.class.equals(method.getDeclaringClass())) {
        try {/*from w w  w . ja v  a2s.co m*/
            return method.invoke(this, args);
        } catch (final InvocationTargetException ite) {
            throw ite.getCause();
        }
    }

    @SuppressWarnings("unchecked")
    final Meta<Object, Object> meta = (Meta<Object, Object>) mapping.get(method);
    return meta.convert(args[0]);
}

From source file:org.jspresso.framework.util.accessor.bean.BeanCollectionAccessor.java

/**
 * {@inheritDoc}/*from w w  w  .ja  v a  2 s  .  c o  m*/
 */
@Override
public void addToValue(Object target, Object value) throws IllegalAccessException, InvocationTargetException {
    if (adderMethod == null) {
        adderMethod = MethodUtils.getMatchingAccessibleMethod(getBeanClass(),
                AccessorInfo.ADDER_PREFIX + capitalizeFirst(getProperty()),
                new Class<?>[] { getElementClass() });
    }
    try {
        adderMethod.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);
    }
}