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.wso2.carbon.analytics.spark.core.udf.adaptor.UDF20Adaptor.java

@Override
public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8,
        Object o9, Object o10, Object o11, Object o12, Object o13, Object o14, Object o15, Object o16,
        Object o17, Object o18, Object o19, Object o20) throws Exception {
    Method udfMethod = udfClass.getDeclaredMethod(udfMethodName, parameterTypes);
    try {/*from  w w w.ja v  a2  s .  c  om*/
        if (Modifier.isStatic(udfMethod.getModifiers())) {
            return udfMethod.invoke(null, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15, o16,
                    o17, o18, o19, o20);
        } else {
            Object udfInstance = udfClass.newInstance();
            return udfMethod.invoke(udfInstance, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14,
                    o15, o16, o17, o18, o19, o20);
        }
    } 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:org.wso2.carbon.analytics.spark.core.udf.adaptor.UDF21Adaptor.java

@Override
public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8,
        Object o9, Object o10, Object o11, Object o12, Object o13, Object o14, Object o15, Object o16,
        Object o17, Object o18, Object o19, Object o20, Object o21) throws Exception {
    Method udfMethod = udfClass.getDeclaredMethod(udfMethodName, parameterTypes);
    try {//  ww w  .j  a v a2s .  c om
        if (Modifier.isStatic(udfMethod.getModifiers())) {
            return udfMethod.invoke(null, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15, o16,
                    o17, o18, o19, o20, o21);
        } else {
            Object udfInstance = udfClass.newInstance();
            return udfMethod.invoke(udfInstance, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14,
                    o15, o16, o17, o18, o19, o20, o21);
        }
    } 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:org.wso2.carbon.analytics.spark.core.udf.adaptor.UDF22Adaptor.java

@Override
public Object call(Object o, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8,
        Object o9, Object o10, Object o11, Object o12, Object o13, Object o14, Object o15, Object o16,
        Object o17, Object o18, Object o19, Object o20, Object o21, Object o22) throws Exception {
    Method udfMethod = udfClass.getDeclaredMethod(udfMethodName, parameterTypes);
    try {/*from  w ww.ja  va  2  s .c o  m*/
        if (Modifier.isStatic(udfMethod.getModifiers())) {
            return udfMethod.invoke(null, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15, o16,
                    o17, o18, o19, o20, o21, o22);
        } else {
            Object udfInstance = udfClass.newInstance();
            return udfMethod.invoke(udfInstance, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14,
                    o15, o16, o17, o18, o19, o20, o21, o22);
        }
    } 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:edu.umich.robot.soar.OLCommandManager.java

/**
 * Convert a wme in to a command instance for processing. If the command
 * returns from this, it is accepted and status is set as such.
 * //from www  .ja  v  a 2  s. c  o  m
 * @param id
 * @return
 * @throws SoarCommandError
 */
public OLCommand newInstance(Identifier id) throws SoarCommandError {
    String name = id.GetAttribute();

    Class<? extends OLCommand> klass = commands.get(name);
    if (klass != null) {
        try {
            Constructor<? extends OLCommand> ctor = klass
                    .getConstructor(new Class<?>[] { Identifier.class, SoarAgent.class });
            OLCommand command = ctor.newInstance(id, agent);
            if (command != null)
                CommandStatus.ACCEPTED.addStatus(id);
            logger.debug(agentPrompt + command);
            return command;

        } catch (InvocationTargetException e) {
            if (e.getCause() instanceof SoarCommandError) {
                SoarCommandError sce = (SoarCommandError) e.getCause();
                CommandStatus.ERROR.addStatus(id, sce.getMessage());
                logger.error(sce.getMessage());
            }
            return null;
        } catch (NoSuchMethodException e) {
            logger.error(e.getMessage());
            return null;
        } catch (IllegalAccessException e) {
            logger.error(e.getMessage());
            return null;
        } catch (InstantiationException e) {
            logger.error(e.getMessage());
            return null;
        }
    }

    logger.warn("No such command: " + name);
    return null;
}

From source file:com.swordlord.gozer.ui.gozerframe.GozerFrameLink.java

@Override
public void onClick() {
    IGozerFrameExtension gfe = null;//  w  w  w.  ja va  2s  .c om

    try {
        Class<? extends IGozerFrameExtension> clazz = getGozerFrameExtension();
        Constructor<? extends IGozerFrameExtension> c = clazz
                .getConstructor(new Class[] { IGozerSessionInfo.class });
        gfe = c.newInstance(new Object[] { _sessionInfo });
    } catch (InvocationTargetException e) {
        LOG.error(e.getCause());
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        LOG.error(e.getCause());
        e.printStackTrace();
    } catch (InstantiationException e) {
        LOG.error(e.getCause());
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        LOG.error(e.getCause());
        e.printStackTrace();
    } catch (SecurityException e) {
        LOG.error(e.getCause());
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        LOG.error(e.getCause());
        e.printStackTrace();
    }

    GozerPage page = null;

    if (_clazz != null) {
        page = GozerPage.getFrame(gfe, _clazz);
    } else {
        page = GozerPage.getFrame(gfe);
    }

    if (page != null) {
        setResponsePage(page);
    } else {
        LOG.error("GozerFile does not exist, is null or empty: " + gfe.getGozerLayoutFileName());
    }
}

From source file:it.tidalwave.northernwind.frontend.impl.ui.ViewBuilder.java

/*******************************************************************************************************************
 *
 * Creates a new View - ViewController pair. They are first instantiated, and then dependency injection by means
 * of constructor parameters occur. Injected fields are: the id, the {@link SiteNode}, any service declared in
 * the Spring context, including {@link Site}; furthermore, a reference of the View is injected in the Controller.
 *
 * @param   id        the view id/*from ww w.  j  av  a2  s.  co m*/
 * @param   siteNode  the {@link SiteNode} the view will be built for
 * @return            the created view
 *
 ******************************************************************************************************************/
@Nonnull
public ViewAndController createViewAndController(final @Nonnull Id id, final @Nonnull SiteNode siteNode)
        throws HttpStatusException {
    log.debug("createViewAndController({}, {})", id, siteNode);

    try {
        final Object view = viewConstructor
                .newInstance(computeConstructorArguments(viewConstructor, id, siteNode));
        final Object controller = viewControllerConstructor
                .newInstance(computeConstructorArguments(viewControllerConstructor, id, siteNode, view));
        return new ViewAndController(view, controller);
    } catch (InvocationTargetException e) {
        if (e.getCause() instanceof BeanCreationException) // FIXME: cumbersome
        {
            if (e.getCause().getCause() instanceof HttpStatusException) {
                throw (HttpStatusException) e.getCause().getCause();
            }
        }

        throw new RuntimeException(e);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:br.com.caelum.vraptor.config.BasicConfiguration.java

public ContainerProvider getProvider() throws ServletException {
    Class<? extends ContainerProvider> providerType = getProviderType();
    logger.info("Using {} as Container Provider", providerType);
    try {/*from   w w w  .  j a v  a 2  s.  c o m*/
        return providerType.getDeclaredConstructor().newInstance();
    } catch (InvocationTargetException e) {
        throw new ServletException(e.getCause());
    } catch (Exception e) {
        throw new ServletException(e);
    }
}

From source file:com.facebook.stetho.inspector.MethodDispatcher.java

public JSONObject dispatch(JsonRpcPeer peer, String methodName, @Nullable JSONObject params)
        throws JsonRpcException {
    MethodDispatchHelper dispatchHelper = findMethodDispatcher(methodName);
    if (dispatchHelper == null) {
        throw new JsonRpcException(new JsonRpcError(JsonRpcError.ErrorCode.METHOD_NOT_FOUND,
                "Not implemented: " + methodName, null /* data */));
    }/* w w w.jav  a 2s.c  o  m*/
    try {
        return dispatchHelper.invoke(peer, params);
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        ExceptionUtil.propagateIfInstanceOf(cause, JsonRpcException.class);
        throw ExceptionUtil.propagate(cause);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (JSONException e) {
        throw new JsonRpcException(
                new JsonRpcError(JsonRpcError.ErrorCode.INTERNAL_ERROR, e.toString(), null /* data */));
    }
}

From source file:libepg.epg.section.sdt.descriptor.ServiceDescriptorTest.java

public ServiceDescriptorTest() throws DecoderException, Throwable {
    try {// w  w  w . j a  v  a2s.c om
        x1 = new Descriptors().getSERVICE_DESCRIPTOR_BYTE();
        sdesc = Descriptors.init(x1);
    } catch (InvocationTargetException ex) {
        throw ex.getCause();
    }
}

From source file:org.libreplan.web.common.ExceptionCatcherProxy.java

public T applyTo(final T instance) {
    return interfaceKlass.cast(Proxy.newProxyInstance(instance.getClass().getClassLoader(),
            new Class[] { interfaceKlass }, new InvocationHandler() {

                @Override/*from   w ww.j  a v a2  s . c o  m*/
                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                    Object result;
                    try {
                        result = method.invoke(instance, args);
                        return result;
                    } catch (InvocationTargetException e) {
                        Throwable cause = e.getCause();
                        if (!handled(cause)) {
                            throw cause;
                        }
                        // we don't know what would be the result, so we
                        // return null
                        return null;
                    }
                }

            }));
}