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.lp.server.util.logger.HvDtoLogger.java

private void findDifference(HvDtoLogClass logAnnotation, Method theMethod, Object object1, Object object2) {
    if (object1 == null || object2 == null)
        return;/*w  w  w .  jav a2 s.  co m*/

    try {
        Object v1 = theMethod.invoke(object1, (Object[]) null);
        Object v2 = theMethod.invoke(object2, (Object[]) null);

        if (isDifferent(v1, v2)) {
            setBaseId(object1);

            if (theMethod.isAnnotationPresent(HvDtoLogComplex.class)) {
                logImpl(v1, v2);
            } else {
                if (theMethod.isAnnotationPresent(HvDtoLogIdCnr.class)) {
                    v1 = getEntityCnr(theMethod, v1);
                    v2 = getEntityCnr(theMethod, v2);
                } else {
                    if (theMethod.isAnnotationPresent(HvDtoLogIdCBez.class)) {
                        v1 = getEntityCBez(theMethod, v1);
                        v2 = getEntityCBez(theMethod, v2);
                    }
                }

                logValues(logAnnotation, getKeyFromMethod(theMethod), getBaseId(object1), v1, v2);
            }
        }
    } catch (InvocationTargetException e) {
        System.out.println("invocation" + e.getMessage());
    } catch (IllegalAccessException e) {
        System.out.println("access" + e.getMessage());
    }
}

From source file:com.netsteadfast.greenstep.aspect.HessianServiceProxyAspect.java

private Object proxyProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable {
    MethodSignature signature = (MethodSignature) pjp.getSignature();
    Annotation[] annotations = pjp.getTarget().getClass().getAnnotations();
    String serviceId = AspectConstants.getServiceId(annotations);

    /**/*from   w  w w. jav  a 2 s. c o  m*/
     * ???? service-bean
     */
    if (!GreenStepHessianUtils.isProxyServiceId(serviceId)) {
        //logger.info( "reject proxy service: " + serviceId );
        return pjp.proceed();
    }

    String userId = StringUtils.defaultString((String) SecurityUtils.getSubject().getPrincipal());

    if (GreenStepHessianUtils.getConfigHessianHeaderCheckValueModeEnable()) {
        /**
         * ???? service-bean
         */
        if (StringUtils.isBlank(userId)) {
            logger.warn("no userId");
            pjp.proceed();
        }

        /**
         * ???? service-bean
         */
        if (GreenStepHessianUtils.isProxyBlockedAccountId(userId)) {
            logger.warn("reject proxy service: " + serviceId + " , blocked userId: " + userId);
            return pjp.proceed();
        }
    }

    String serviceInterfacesName = "";
    Class<?> serviceInterfaces[] = pjp.getTarget().getClass().getInterfaces();
    for (Class<?> clazz : serviceInterfaces) {
        if (clazz.getName().indexOf(".service.") > -1) {
            serviceInterfacesName = clazz.getName();
        }
    }
    if (StringUtils.isBlank(serviceInterfacesName)) {
        logger.error("error no service interface: " + serviceId);
        throw new Exception("error no service interface: " + serviceId);
    }

    String url = GreenStepHessianUtils.getServiceUrl(serviceId);
    String theSystemPath = ApplicationSiteUtils.getHost(Constants.getSystem()) + "/"
            + ApplicationSiteUtils.getContextPath(Constants.getSystem());

    /**
     * ?????, ? HessianServiceProxyAspect ? (server-remote???)
     *  http://127.0.0.1:8080/
     *  hessian.enable=Y ???, ?url hessian.serverUrl=http://127.0.0.1:8080/
     * 
     */
    if (url.indexOf(theSystemPath) > -1) {
        logger.error("cannot open same-server. now system contextPath = " + theSystemPath
                + " , but proxy url = " + url);
        throw new Exception("cannot open same-server. now system contextPath = " + theSystemPath
                + " , but proxy url = " + url);
    }

    logger.info("proxy url = " + url);
    HessianProxyFactory factory = null;
    Object proxyServiceObject = null;
    if (GreenStepHessianUtils.getConfigHessianHeaderCheckValueModeEnable()) { // ?checkValue?
        factory = new GreenStepHessianProxyFactory();
        ((GreenStepHessianProxyFactory) factory)
                .setHeaderCheckValue(GreenStepHessianUtils.getEncAuthValue(userId));
        proxyServiceObject = ((GreenStepHessianProxyFactory) factory)
                .createForHeaderMode(Class.forName(serviceInterfacesName), url);
    } else { // ?checkValue?
        factory = new HessianProxyFactory();
        proxyServiceObject = factory.create(Class.forName(serviceInterfacesName), url);
    }
    Method[] proxyObjectMethods = proxyServiceObject.getClass().getMethods();
    Method proxyObjectMethod = null;
    if (null == proxyObjectMethods) {
        logger.error("error no find proxy method: " + serviceId);
        throw new Exception("error no find proxy method: " + serviceId);
    }
    for (Method m : proxyObjectMethods) {
        if (m.getName().equals(signature.getMethod().getName())
                && Arrays.equals(m.getParameterTypes(), signature.getMethod().getParameterTypes())) {
            proxyObjectMethod = m;
        }
    }

    if (null == proxyObjectMethod) {
        logger.error("error no execute proxy method: " + serviceId);
        throw new Exception("error no execute proxy method: " + serviceId);
    }

    Object resultObj = null;
    try {
        resultObj = proxyObjectMethod.invoke(proxyServiceObject, pjp.getArgs());
        this.setReCalculateSizePageOfForPageFindGridResult(resultObj, pjp.getArgs());
    } catch (InvocationTargetException e) {
        if (e.getMessage() != null) {
            throw new ServiceException(e.getMessage().toString());
        }
        if (e.getTargetException().getMessage() != null) {
            throw new ServiceException(e.getTargetException().getMessage().toString());
        }
        throw e;
    } catch (Exception e) {
        logger.error(e.getMessage().toString());
        throw e;
    }
    logger.info("proxy success: " + serviceId + " method: " + proxyObjectMethod.getName());
    return resultObj;
}

From source file:no.sesat.search.datamodel.BeanDataNodeInvocationHandler.java

@Override
public Object invoke(final Object obj, final Method method, final Object[] args) throws Throwable {

    assureAccessAllowed(method);/*from   w w w  .j  ava 2 s .  com*/

    // try our dataObject|dataNode delegated-properties
    try {
        return super.invoke(obj, method, args);

    } catch (IllegalArgumentException iae) {
        LOG.debug("property not one of our own. " + iae.getMessage());
    }

    // try non-(dataObject|dataNode) delegated-properties
    try {
        return dataObject.invoke(obj, method, args);

    } catch (IllegalArgumentException iae) {
        LOG.debug("property not from delegate", iae);
    }

    // try pure self methods
    try {
        return method.invoke(this, args);

    } catch (IllegalAccessException iae) {
        LOG.info(iae.getMessage(), iae);
    } catch (IllegalArgumentException iae) {
        LOG.info(iae.getMessage(), iae);
    } catch (InvocationTargetException ite) {
        LOG.info(ite.getMessage(), ite);
    }

    throw new IllegalArgumentException("Method to invoke doesn't map to bean property");
}

From source file:org.castor.cache.distributed.OsCacheFactory.java

/**
 * Normally called to initialize OsCache. To be able to test the method without
 * having <code>com.opensymphony.oscache.general.GeneralCacheAdministrator</code>
 * implementation, it can also be called with a test implementations classname.
 * //from  w ww.j av  a2 s  . c o  m
 * @param implementation Cache implementation classname to initialize.
 * @param classLoader A ClassLoader instance.
 * @return A Cache instance.
 * @throws CacheAcquireException Problem instantiating a cache instance.
 */
@SuppressWarnings("unchecked")
public synchronized Cache<K, V> getCache(final String implementation, final ClassLoader classLoader)
        throws CacheAcquireException {
    ClassLoader loader = classLoader;
    if (loader == null) {
        loader = Thread.currentThread().getContextClassLoader();
    }

    if (_cache == null) {
        try {
            _cache = loader.loadClass(implementation).newInstance();
        } catch (ClassNotFoundException cnfe) {
            String msg = "Cannot find class " + implementation + ".";
            LOG.error(msg, cnfe);
            throw new CacheAcquireException(msg, cnfe);
        } catch (IllegalAccessException iae) {
            String msg = "Illegal access with class " + implementation + ".";
            LOG.error(msg, iae);
            throw new CacheAcquireException(msg, iae);
        } catch (InstantiationException ie) {
            String msg = "Cannot create instance of " + implementation + ".";
            LOG.error(msg, ie);
            throw new CacheAcquireException(msg, ie);
        }
    }

    Cache<K, V> cache = null;
    try {
        Class<?> cls = loader.loadClass(getCacheClassName());
        Constructor<?> cst = cls.getConstructor(new Class[] { Object.class });
        cache = (Cache<K, V>) cst.newInstance(new Object[] { _cache });
    } catch (ClassNotFoundException cnfe) {
        String msg = "Cannot find class " + getCacheClassName() + ".";
        LOG.error(msg, cnfe);
        throw new CacheAcquireException(msg, cnfe);
    } catch (NoSuchMethodException nsme) {
        String msg = "NoSuchMethodException";
        LOG.error(msg, nsme);
        throw new CacheAcquireException(msg, nsme);
    } catch (IllegalAccessException iae) {
        String msg = "Illegal access with class " + getCacheClassName() + ".";
        LOG.error(msg, iae);
        throw new CacheAcquireException(msg, iae);
    } catch (InstantiationException ie) {
        String msg = "Cannot create instance of " + getCacheClassName() + ".";
        LOG.error(msg, ie);
        throw new CacheAcquireException(msg, ie);
    } catch (InvocationTargetException ite) {
        String msg = "InvocationTargetException";
        LOG.error(msg, ite);
        throw new IllegalStateException(ite.getMessage());
    }

    return cache;
}

From source file:org.sonar.ide.eclipse.internal.ui.wizards.ServerLocationWizardPage.java

/**
 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
 */// ww w .j  a  v  a  2s. c om
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 2;
    layout.verticalSpacing = 9;
    Label label = new Label(container, SWT.NULL);
    label.setText(Messages.ServerLocationWizardPage_label_host);
    serverUrlText = new Text(container, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    serverUrlText.setLayoutData(gd);
    serverUrlText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    // Sonar Server Username
    Label labelUsername = new Label(container, SWT.NULL);
    labelUsername.setText(Messages.ServerLocationWizardPage_label_username);
    serverUsernameText = new Text(container, SWT.BORDER | SWT.SINGLE);
    serverUsernameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Sonar Server password
    Label labelPassword = new Label(container, SWT.NULL);
    labelPassword.setText(Messages.ServerLocationWizardPage_label_password);
    serverPasswordText = new Text(container, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD);
    serverPasswordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Sonar test connection button
    testConnectionButton = new Button(container, SWT.PUSH);
    testConnectionButton.setText(Messages.ServerLocationWizardPage_action_test);
    testConnectionButton.setToolTipText(Messages.ServerLocationWizardPage_action_test_tooltip);
    testConnectionButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    testConnectionButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // We need those variables - in other case we would get an IllegalAccessException
            final String serverUrl = getServerUrl();
            final String username = getUsername();
            final String password = getPassword();
            try {
                getWizard().getContainer().run(true, true, new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        monitor.beginTask("Testing", IProgressMonitor.UNKNOWN);
                        try {
                            ConnectionTestResult result = SonarCorePlugin.getServerConnectionTester()
                                    .testSonar(serverUrl, username, password);
                            switch (result) {
                            case OK:
                                status = new Status(IStatus.OK, ISonarConstants.PLUGIN_ID,
                                        Messages.ServerLocationWizardPage_msg_connected);
                                break;
                            case AUTHENTICATION_ERROR:
                                status = new Status(IStatus.ERROR, ISonarConstants.PLUGIN_ID,
                                        Messages.ServerLocationWizardPage_msg_authentication_error);
                                break;
                            case CONNECT_ERROR:
                                status = new Status(IStatus.ERROR, ISonarConstants.PLUGIN_ID,
                                        Messages.ServerLocationWizardPage_msg_connection_error);
                                break;
                            }
                        } catch (OperationCanceledException e) {
                            throw new InterruptedException();
                        } catch (Exception e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (InvocationTargetException e1) {
                LoggerFactory.getLogger(getClass()).error(e1.getMessage(), e1);

                status = new Status(IStatus.ERROR, ISonarConstants.PLUGIN_ID,
                        Messages.ServerLocationWizardPage_msg_error);
            } catch (InterruptedException e1) { // NOSONAR - canceled
                status = Status.CANCEL_STATUS;
            }
            getWizard().getContainer().updateButtons();

            String message = status.getMessage();
            switch (status.getSeverity()) {
            case IStatus.OK:
                setMessage(message, IMessageProvider.INFORMATION);
                break;
            default:
                setMessage(message, IMessageProvider.ERROR);
                break;
            }
        }
    });

    initialize();
    dialogChanged();
    setControl(container);
}

From source file:de.mpg.escidoc.services.fledgeddata.webservice.oaiServlet.java

public String getResult(HttpServletRequest request, HttpServletResponse response, HashMap serverVerbs)
        throws Throwable {
    try {/*from  w w w . ja v  a  2 s  .  co  m*/
        String verb = request.getParameter("verb");
        String result;
        Class verbClass = null;
        verbClass = (Class) serverVerbs.get(verb);
        if (verbClass == null) {
            verbClass = (Class) serverVerbs.get("BadVerb");
        }

        Method construct = verbClass.getMethod("construct",
                new Class[] { Properties.class, HttpServletRequest.class, HttpServletResponse.class });
        try {
            result = (String) construct.invoke(null, new Object[] { properties, request, response });
        } catch (InvocationTargetException e) {
            throw e.getTargetException();
        }
        return result;

    } catch (NoSuchMethodException e) {
        throw new OAIInternalServerError(e.getMessage());
    } catch (IllegalAccessException e) {
        throw new OAIInternalServerError(e.getMessage());
    }
}

From source file:lius.index.xml.XmlFileIndexer.java

private void extractDataFromElements(Object xmlDoc, Collection liusFields, Collection resColl) {
    Iterator it = liusFields.iterator();
    while (it.hasNext()) {
        Object field = it.next();
        if (field instanceof LiusField) {
            LiusField lf = (LiusField) field;
            if (lf.getOcurSep() != null) {
                String cont = concatOccurance(xmlDoc, lf.getXpathSelect(), lf.getOcurSep());
                lf.setValue(cont);/*from  w w w . j  av  a2  s  .c o m*/
                resColl.add(lf);
            } else {
                try {
                    JDOMXPath xp = new JDOMXPath(lf.getXpathSelect());
                    xp.setNamespaceContext(nsc);
                    List selectList = xp.selectNodes(xmlDoc);
                    Iterator i = selectList.iterator();
                    while (i.hasNext()) {
                        LiusField lfoccur = new LiusField();
                        BeanUtils.copyProperties(lfoccur, lf);
                        Object selection = (Object) i.next();
                        if (selection instanceof Element) {
                            Element elem = (Element) selection;
                            if (elem.getText().trim() != null && elem.getText().trim() != "") {
                                lfoccur.setValue(elem.getText());
                                resColl.add(lfoccur);
                            }
                        } else if (selection instanceof Attribute) {
                            Attribute att = (Attribute) selection;
                            lfoccur.setValue(att.getValue());
                            resColl.add(lfoccur);
                        } else if (selection instanceof Text) {
                            Text text = (Text) selection;
                            lfoccur.setValue(text.getText());
                            resColl.add(lfoccur);
                        } else if (selection instanceof CDATA) {
                            CDATA cdata = (CDATA) selection;
                            lfoccur.setValue(cdata.getText());
                            resColl.add(lfoccur);
                        } else if (selection instanceof Comment) {
                            Comment com = (Comment) selection;
                            lfoccur.setValue(com.getText());
                            resColl.add(lfoccur);
                        } else if (selection instanceof ProcessingInstruction) {
                            ProcessingInstruction pi = (ProcessingInstruction) selection;
                            lfoccur.setValue(pi.getData());
                            resColl.add(lfoccur);
                        } else if (selection instanceof EntityRef) {
                            EntityRef er = (EntityRef) selection;
                            lfoccur.setValue(er.toString());
                            resColl.add(lfoccur);
                        }
                    }
                } catch (JaxenException e) {
                    logger.error(e.getMessage());
                } catch (InvocationTargetException ex) {
                    logger.error(ex.getMessage());
                } catch (IllegalAccessException ex) {
                    logger.error(ex.getMessage());
                }

            }
        } else {
            resColl.add(field);
        }
    }

}

From source file:com.linecorp.bot.spring.boot.support.LineMessageHandlerSupport.java

@VisibleForTesting
void dispatch(Event event) {
    try {/*from   w w w . j  a v a  2 s .co m*/
        dispatchInternal(event);
    } catch (InvocationTargetException e) {
        log.trace("InvocationTargetException occurred.", e);
        log.error(e.getCause().getMessage(), e.getCause());
    } catch (Error | Exception e) {
        log.error(e.getMessage(), e);
    }
}

From source file:org.locationtech.udig.processingtoolbox.tools.MergeFeaturesDialog.java

@Override
protected void okPressed() {
    if (!existCheckedItem(inputTable)) {
        openInformation(getShell(), Messages.MergeFeaturesDialog_Warning);
        return;//www.  j ava  2  s.  c om
    }

    // check file
    File outputFile = new File(locationView.getFile());
    if (outputFile.exists()) {
        String msg = Messages.ProcessExecutionDialog_overwriteconfirm;
        if (MessageDialog.openConfirm(getParentShell(), getShell().getText(), msg)) {
            if (!MapUtils.confirmSpatialFile(outputFile)) {
                msg = Messages.ProcessExecutionDialog_deletefailed;
                MessageDialog.openInformation(getParentShell(), getShell().getText(), msg);
                return;
            }
        } else {
            return;
        }
    }

    try {
        PlatformUI.getWorkbench().getProgressService().run(false, true, this);
        openInformation(getShell(), Messages.General_Completed);
        super.okPressed();
    } catch (InvocationTargetException e) {
        MessageDialog.openError(getShell(), Messages.General_Error, e.getMessage());
    } catch (InterruptedException e) {
        MessageDialog.openInformation(getShell(), Messages.General_Cancelled, e.getMessage());
    }
}

From source file:com.turbospaces.model.BO.java

/**
 * create new instance of class via fast cglib constructor
 * //from  w  w w.  j av  a  2s . co m
 * @return new instance of {@link BO}'s underlying type
 */
public Object newInstance() {
    try {
        return fastConstructor.newInstance();
    } catch (InvocationTargetException e) {
        Log.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}