Example usage for java.lang.reflect InvocationTargetException getMessage

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.amalto.workbench.export.ImportItemsWizard.java

protected void parse() {
    try {/*w  w  w.j  a v  a  2s .  co m*/
        boolean importFromArchieve = zipBtn.getSelection();
        if (importFromArchieve) {
            importFolder = System.getProperty("java.io.tmpdir") + File.separator + "temp" + File.separator //$NON-NLS-1$//$NON-NLS-2$
                    + "subfolder"//$NON-NLS-1$
                    + System.currentTimeMillis();
        }
        if (folderBtn.getSelection()) {
            importFolder = folder.getText().getText();
        }
        getContainer().run(true, false, new ImportProcess(importFromArchieve, getZipFilePath()));
    } catch (InvocationTargetException e) {
        log.error(e.getMessage(), e);
    } catch (InterruptedException e) {
        log.debug(e.getMessage(), e);
    }
}

From source file:org.glowroot.central.SyntheticMonitorService.java

private SyntheticRunResult runJavaInternal(Constructor<?> defaultConstructor, Method testMethod, Object testArg,
        long startTick) throws Exception {
    long captureTime;
    long durationNanos;
    try {/* www. j a v a  2s .  co  m*/
        testMethod.invoke(defaultConstructor.newInstance(), testArg);
        // capture time and duration before calling driver.quit()
        captureTime = clock.currentTimeMillis();
        durationNanos = ticker.read() - startTick;
    } catch (InvocationTargetException e) {
        logger.debug(e.getMessage(), e);
        Throwable throwable = e.getTargetException();
        if (throwable instanceof InterruptedException) {
            // probably shutdown requested (see close method above)
            throw (InterruptedException) throwable;
        }
        return ImmutableSyntheticRunResult.builder().captureTime(clock.currentTimeMillis())
                .durationNanos(ticker.read() - startTick).throwable(throwable).build();
    } finally {
        if (testArg instanceof JBrowserDriver) {
            // quit() can hang (easily reproducible on test that doesn't use testArg at all)
            ((JBrowserDriver) testArg).kill();
        }
    }
    return ImmutableSyntheticRunResult.builder().captureTime(captureTime).durationNanos(durationNanos).build();
}

From source file:org.hyperic.snmp.SNMPSessionCache.java

public Object invoke(Object proxy, Method method, Object[] args) throws SNMPException {
    SNMPCacheObject cacheVal = null;/*from   w  w w.  ja v a2s. c  o  m*/

    HashMap cache = null;

    Object cacheKey = null;
    Object retval;

    String name = method.getName();

    long timeNow = 0;

    // Perhaps more later...
    if (name.equals("getBulk")) {
        cache = this.bulkCache;

        cacheKey = args[0];
    } else if (name.equals("getTable")) {
        cache = this.tableCache;

        cacheKey = new Integer(args[0].hashCode() ^ args[1].hashCode());
    } else if (name.equals("getColumn")) {
        cache = this.columnCache;

        cacheKey = args[0];
    }

    if (cache != null) {
        timeNow = System.currentTimeMillis();

        cacheVal = getFromCache(timeNow, cache, name, cacheKey);

        if (cacheVal.value != null) {
            return cacheVal.value;
        }
    }

    try {
        retval = method.invoke(this.session, args);
    } catch (InvocationTargetException e) {
        Throwable t = ((InvocationTargetException) e).getTargetException();

        String msg;

        if (t instanceof MIBLookupException) {
            throw (MIBLookupException) t;
        }

        if (t instanceof SNMPException) {
            msg = "";
        } else {
            msg = t.getClass().getName() + ": ";
        }

        msg += t.getMessage() + " invoking: " + invokerToString(name, args, cacheKey);

        throw new SNMPException(msg, t);
    } catch (Exception e) {
        String msg = e.getClass().getName() + ": " + e.getMessage() + " invoking: "
                + invokerToString(name, args, cacheKey);

        throw new SNMPException(msg, e);
    }

    if (cacheVal != null) {
        cacheVal.value = retval;
        cacheVal.timestamp = timeNow;

        if (log.isDebugEnabled()) {
            log.debug(invokerToString(name, args, cacheKey) + " took: " + new StopWatch(timeNow));
        }
    }

    return retval;
}

From source file:org.artifactory.support.core.bundle.AbstractSupportBundleService.java

/**
 * Fetches Throwable cause// w  ww.j  a  v  a 2 s  .  com
 *
 * @param e exception to check
 * @return actual exception cause
 */
private String getCause(InvocationTargetException e) {
    return (e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
}

From source file:com.liusoft.dlog4j.action.ActionExtend.java

/**
 * Action???????? //from   w  w  w. j a v a  2  s .c o m
 * 1.??eventSubmit_XxxxdoXxxx
 * 2.?__method?do
 */
public final ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req,
        HttpServletResponse res) throws Exception {
    ActionForward af = beforeExecute(mapping, form, req, res);
    if (af != null)
        return af;

    String param = null;
    String value = null;

    String __method = req.getParameter(METHOD_IDENT_PARAM);
    if (StringUtils.isNotBlank(__method)) {
        param = METHOD_PREFIX + __method;
    } else {
        for (Enumeration params = req.getParameterNames(); params.hasMoreElements();) {
            String t_param = (String) params.nextElement();
            if (t_param.startsWith(SUBMIT_BUTTON_PREFIX)) {
                value = req.getParameter(t_param);
                param = METHOD_PREFIX + t_param.substring(SUBMIT_BUTTON_PREFIX.length());
                break;
            }
        }
    }

    if (param == null)
        param = "doDefault";

    try {
        return callActionMethod(mapping, form, req, res, param, value);
    } catch (InvocationTargetException e) {
        Throwable t = e.getCause();
        if (t instanceof IllegalAccessException) {
            res.sendError(HttpServletResponse.SC_FORBIDDEN);
            return null;
        }
        log.error("Exception occur when calling " + param + " in action:" + getClass().getName(), t);
        if (t instanceof Exception)
            throw (Exception) t;
        else
            throw new Exception(t);
    } catch (NoSuchMethodException e) {
        res.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
        return null;
    } finally {
        afterExecute(mapping, form, req, res);
    }
}

From source file:org.gluewine.rest_server.RESTServlet.java

/**
 * Executes the {@link RESTMethod} specified using the given parameters and returns the
 * result./*  w w  w.  ja  va 2 s.  com*/
 *
 * @param method The method to execute.
 * @param params The parameters.
 * @return The result of the method invocation.
 * @throws IOException If an error occurs.
 */
@ContextInitializer
public Object executeMethod(RESTMethod method, Object[] params) throws IOException {
    try {
        if (logger.isDebugEnabled())
            logger.debug("Executing method: " + method.getMethod());
        Object result = method.getMethod().invoke(method.getObject(), params);
        if (logger.isDebugEnabled())
            logger.debug("Method returned: " + result);
        return result;
    } catch (InvocationTargetException e) {
        Throwable c = e.getCause();
        ErrorLogger.log(getClass(), c);
        throw new IOException(c.getMessage());
    } catch (Throwable e) {
        ErrorLogger.log(getClass(), e);
        if (e instanceof IOException)
            throw (IOException) e;
        else
            throw new IOException(e.getMessage());
    }
}

From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java

private boolean buildNotificationIcons(final int iconResId, final String imageIconUrl,
        final String imageSmallIconUrl, final Object notificationBuilder) {
    try {/*w ww . j  a va2  s  . c  om*/
        if (imageIconUrl != null) {
            try {
                setLargeIconMethod.invoke(notificationBuilder,
                        new DownloadImageTask().execute(imageIconUrl).get());
            } catch (final InterruptedException e) {
                log.error("Interrupted when downloading image : " + e.getMessage(), e);
            } catch (final ExecutionException e) {
                log.error("Failed execute download image thread : " + e.getMessage(), e);
            }
        }
        if (imageSmallIconUrl != null && iconClass != null
                && android.os.Build.VERSION.SDK_INT >= ANDROID_MARSHMALLOW) {
            try {
                final Bitmap iconBitmap = new DownloadImageTask().execute(imageSmallIconUrl).get();
                setSmallIconMethod.invoke(notificationBuilder,
                        createWithBitmapMethod.invoke(iconClass, iconBitmap));
            } catch (final InterruptedException e) {
                log.error("Interrupted when downloading small icon : " + e.getMessage(), e);
                setSmallIconResIdMethod.invoke(notificationBuilder, iconResId);
            } catch (final ExecutionException e) {
                log.error("Failed execute download image small icon thread : " + e.getMessage(), e);
                setSmallIconResIdMethod.invoke(notificationBuilder, iconResId);
            }
        } else {
            setSmallIconResIdMethod.invoke(notificationBuilder, iconResId);
        }
        return true;
    } catch (final InvocationTargetException ex) {
        log.debug("Can't invoke notification builder methods. : " + ex.getMessage(), ex);
        return false;
    } catch (final IllegalAccessException ex) {
        log.debug("Can't access notification builder methods. : " + ex.getMessage(), ex);
        return false;
    }
}

From source file:net.rim.ejde.internal.ui.views.profiler.ProfilerView.java

public void openProfileVis() {
    File tmpFile = getTmpFile();//from   w  w  w.  ja va  2 s . com
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(ContextManager.getActiveWorkbenchShell());
    SaveRawDataRunnale runnable = new SaveRawDataRunnale(tmpFile, this);
    try {
        dialog.run(false, true, runnable);
    } catch (InvocationTargetException e) {
        log.error(e);
        MessageDialog.openError(ContextManager.getActiveWorkbenchShell(), e.getMessage(),
                Messages.ErrorHandler_DIALOG_TITLE);
        return;
    } catch (InterruptedException e) {
        log.error(e);
        MessageDialog.openError(ContextManager.getActiveWorkbenchShell(), e.getMessage(),
                Messages.ErrorHandler_DIALOG_TITLE);
        return;
    }
    try {
        Desktop.getDesktop().open(tmpFile);
    } catch (IOException e) {
        log.error(e);
        MessageDialog.openError(ContextManager.getActiveWorkbenchShell(), Messages.ErrorHandler_DIALOG_TITLE,
                Messages.BBProfileVis_Not_Installed_ErrMsg);
    }
}

From source file:net.rim.ejde.internal.ui.views.profiler.ProfilerView.java

/**
 * Save view content to a XML file.//ww  w.ja  v a  2  s  .co  m
 * <p>
 * <b>subclasses need to override this method.</b>
 */
public void saveXML() {
    File xmlFile = chooseDataFile();
    if (xmlFile == null) {
        return;
    }
    if (!xmlFile.exists()) {
        xmlFile = ProjectUtils.createFile(xmlFile);
        if (xmlFile == null || !xmlFile.exists()) {
            return;
        }
    }
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(ContextManager.getActiveWorkbenchShell());
    SaveDataRunnale runnable = new SaveDataRunnale(xmlFile, this);
    try {
        dialog.run(false, true, runnable);
    } catch (InvocationTargetException e) {
        log.error(e);
        MessageDialog.openError(ContextManager.getActiveWorkbenchShell(), e.getMessage(),
                Messages.ErrorHandler_DIALOG_TITLE);
    } catch (InterruptedException e) {
        log.error(e);
        MessageDialog.openError(ContextManager.getActiveWorkbenchShell(), e.getMessage(),
                Messages.ErrorHandler_DIALOG_TITLE);
    }
}

From source file:net.rim.ejde.internal.ui.views.profiler.ProfilerView.java

/**
 * Save raw data of the view content to a XML file.
 * <p>/*from ww w .j  av  a  2  s  .co m*/
 * <b>subclasses need to override this method.</b>
 */
public void saveRawToXML() {
    File xmlFile = chooseRawDataFile();
    if (xmlFile == null) {
        return;
    }
    if (!xmlFile.exists()) {
        xmlFile = ProjectUtils.createFile(xmlFile);
        if (xmlFile == null || !xmlFile.exists()) {
            return;
        }
    }
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(ContextManager.getActiveWorkbenchShell());
    SaveRawDataRunnale runnable = new SaveRawDataRunnale(xmlFile, this);
    try {
        dialog.run(false, true, runnable);
    } catch (InvocationTargetException e) {
        log.error(e);
        MessageDialog.openError(ContextManager.getActiveWorkbenchShell(), e.getMessage(),
                Messages.ErrorHandler_DIALOG_TITLE);
    } catch (InterruptedException e) {
        log.error(e);
        MessageDialog.openError(ContextManager.getActiveWorkbenchShell(), e.getMessage(),
                Messages.ErrorHandler_DIALOG_TITLE);
    }
}