Example usage for java.lang NoSuchMethodException getMessage

List of usage examples for java.lang NoSuchMethodException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.myjeeva.poi.ExcelWorkSheetHandler.java

private void assignValue(Object targetObj, String cellReference, String value) {
    if (null == targetObj || StringUtils.isEmpty(cellReference) || StringUtils.isEmpty(value)) {
        return;//from  w ww.  j  a  v  a  2s.com
    }

    try {
        String propertyName = this.cellMapping.get(cellReference);
        if (null == propertyName) {
            LOG.error("Cell mapping doesn't exists!");
        } else {
            PropertyUtils.setSimpleProperty(targetObj, propertyName, value);
        }
    } catch (IllegalAccessException iae) {
        LOG.error(iae.getMessage());
    } catch (InvocationTargetException ite) {
        LOG.error(ite.getMessage());
    } catch (NoSuchMethodException nsme) {
        LOG.error(nsme.getMessage());
    }
}

From source file:org.kuali.rice.krad.uif.service.impl.ExpressionEvaluatorServiceImpl.java

/**
 * Registers custom functions for el expressions with the given context
 *
 * @param context - context instance to register functions to
 *//*from w w w. j ava 2s. co  m*/
protected void addCustomFunctions(StandardEvaluationContext context) {
    try {
        // TODO: possibly reflect ExpressionFunctions and add automatically
        context.registerFunction("isAssignableFrom", ExpressionFunctions.class
                .getDeclaredMethod("isAssignableFrom", new Class[] { Class.class, Class.class }));
        context.registerFunction("empty",
                ExpressionFunctions.class.getDeclaredMethod("empty", new Class[] { Object.class }));
        context.registerFunction("getName",
                ExpressionFunctions.class.getDeclaredMethod("getName", new Class[] { Class.class }));
        context.registerFunction("getParm", ExpressionFunctions.class.getDeclaredMethod("getParm",
                new Class[] { String.class, String.class, String.class }));
        context.registerFunction("getParmInd", ExpressionFunctions.class.getDeclaredMethod("getParmInd",
                new Class[] { String.class, String.class, String.class }));
        context.registerFunction("hasPerm", ExpressionFunctions.class.getDeclaredMethod("hasPerm",
                new Class[] { String.class, String.class }));
        context.registerFunction("hasPermDtls", ExpressionFunctions.class.getDeclaredMethod("hasPermDtls",
                new Class[] { String.class, String.class, Map.class, Map.class }));
        context.registerFunction("hasPermTmpl", ExpressionFunctions.class.getDeclaredMethod("hasPermTmpl",
                new Class[] { String.class, String.class, Map.class, Map.class }));
    } catch (NoSuchMethodException e) {
        LOG.error("Custom function for el expressions not found: " + e.getMessage());
        throw new RuntimeException("Custom function for el expressions not found: " + e.getMessage(), e);
    }
}

From source file:com.myjeeva.poi.ExcelWorkSheetHandler.java

private String getPropertyValue(Object targetObj, String propertyName) {
    String value = "";
    if (null == targetObj || StringUtils.isBlank(propertyName)) {
        LOG.error("targetObj or propertyName is null, both require to retrieve a value");
        return value;
    }//w  w  w .java 2 s . co m

    try {
        if (PropertyUtils.isReadable(targetObj, propertyName)) {
            Object v = PropertyUtils.getSimpleProperty(targetObj, propertyName);
            if (null != v && StringUtils.isNotBlank(v.toString())) {
                value = v.toString();
            }
        } else {
            LOG.error("Given property (" + propertyName + ") is not readable!");
        }
    } catch (IllegalAccessException iae) {
        LOG.error(iae.getMessage());
    } catch (InvocationTargetException ite) {
        LOG.error(ite.getMessage());
    } catch (NoSuchMethodException nsme) {
        LOG.error(nsme.getMessage());
    }
    return value;
}

From source file:edu.cornell.mannlib.vedit.util.OperationUtils.java

public static void beanSetAndValidate(Object newObj, String field, String value, EditProcessObject epo) {
    Class<?> cls = (epo.getBeanClass() != null) ? epo.getBeanClass() : newObj.getClass();
    Class<?>[] paramList = new Class[1];
    paramList[0] = String.class;
    boolean isInt = false;
    boolean isBoolean = false;
    Method setterMethod = null;/* w  w w . j  a  va  2s.co  m*/
    try {
        setterMethod = cls.getMethod("set" + field, paramList);
    } catch (NoSuchMethodException e) {
        // let's try int
        paramList[0] = int.class;
        try {
            setterMethod = cls.getMethod("set" + field, paramList);
            isInt = true;
        } catch (NoSuchMethodException f) {
            // let's try boolean
            paramList[0] = boolean.class;
            try {
                setterMethod = cls.getMethod("set" + field, paramList);
                isBoolean = true;
                log.debug("found boolean field " + field);
            } catch (NoSuchMethodException g) {
                log.error("beanSet could not find an appropriate String, int, or boolean setter method for "
                        + field);
            }

        }
    }
    Object[] arglist = new Object[1];
    if (isInt)
        arglist[0] = Integer.decode(value);
    else if (isBoolean)
        arglist[0] = (value.equalsIgnoreCase("TRUE"));
    else
        arglist[0] = value;
    try {
        setterMethod.invoke(newObj, arglist);
    } catch (Exception e) {
        log.error("Couldn't invoke method");
        log.error(e.getMessage());
        log.error(field + " " + arglist[0]);
    }
}

From source file:org.atricore.idbus.capabilities.sso.main.binding.SamlR2SoapBinding.java

@Override
public Object sendMessage(MediationMessage message) throws IdentityMediationException {

    if (logger.isTraceEnabled())
        logger.trace("Sending new SAML 2.0 message using SOAP Binding");

    EndpointDescriptor endpoint = message.getDestination();

    String soapEndpoint = endpoint.getLocation();

    // ---------------------------------------------------------
    // Setup CXF Client
    // ---------------------------------------------------------
    Service service = Service.create(SAMLR2MessagingConstants.SERVICE_NAME);
    service.addPort(SAMLR2MessagingConstants.PORT_NAME, javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING,
            endpoint.getLocation());// w ww .j  a v a 2s  .c  o  m

    Object content = message.getContent();

    if (!(content instanceof RequestAbstractType)) {
        throw new IdentityMediationException("Unsupported content " + content);
    }

    String soapMethodName = content.getClass().getSimpleName();
    soapMethodName = "saml" + soapMethodName.substring(0, soapMethodName.length() - 4); // Remove Type

    if (logger.isTraceEnabled())
        logger.trace("Using soap method [" + soapMethodName + "]");

    SAMLRequestPortType port = service.getPort(SAMLR2MessagingConstants.PORT_NAME, SAMLRequestPortType.class);

    if (logger.isTraceEnabled())
        logger.trace("Sending SSO SOAP Request: " + content);

    try {
        Method soapMethod = port.getClass().getMethod(soapMethodName, content.getClass());

        Object o = soapMethod.invoke(port, content);

        if (logger.isTraceEnabled())
            logger.trace("Received SSO SOAP Response: " + o);

        return o;

    } catch (NoSuchMethodException e) {
        throw new IdentityMediationException(
                "SOAP Method not impelmented " + soapMethodName + ": " + e.getMessage(), e);

    } catch (Exception e) {
        throw new IdentityMediationException("SOAP error: " + e.getMessage(), e);
    }

}

From source file:org.kuali.rice.kns.util.ActionFormUtilMap.java

/**
 * This method parses from the key the actual method to run.
 *
 * @see java.util.Map#get(java.lang.Object)
 *///from w w  w .jav a  2 s.  co m
@Override
public Object get(Object key) {
    if (cacheValueFinderResults) {
        if (super.containsKey(key)) {
            // doing a 2 step retrieval allows us to also cache the null key correctly
            Object cachedObject = super.get(key);
            return cachedObject;
        }
    }
    String[] methodKey = StringUtils.split((String) key,
            KRADConstants.ACTION_FORM_UTIL_MAP_METHOD_PARM_DELIMITER);

    String methodToCall = methodKey[0];

    // handle method calls with more than one parameter
    Object[] methodParms = new Object[methodKey.length - 1];
    Class[] methodParmsPrototype = new Class[methodKey.length - 1];
    for (int i = 1; i < methodKey.length; i++) {
        methodParms[i - 1] = methodKey[i];
        methodParmsPrototype[i - 1] = Object.class;
    }

    Method method = null;
    try {
        method = ActionFormUtilMap.class.getMethod(methodToCall, methodParmsPrototype);
    } catch (SecurityException e) {
        throw new RuntimeException(
                "Unable to object handle on method given to ActionFormUtilMap: " + e.getMessage());
    } catch (NoSuchMethodException e1) {
        throw new RuntimeException(
                "Unable to object handle on method given to ActionFormUtilMap: " + e1.getMessage());
    }

    Object methodValue = null;
    try {
        methodValue = method.invoke(this, methodParms);
    } catch (Exception e) {
        throw new RuntimeException("Unable to invoke method " + methodToCall, e);
    }

    if (cacheValueFinderResults) {
        super.put(key, methodValue);
    }

    return methodValue;
}

From source file:com.eu.evaluation.server.service.impl.DictionaryServiceImpl.java

private void initField(EntityEnum ee, ObjectDictionary od) {
    Field[] fields = BeanUtils.getDeclaredFields(ee.getEntityClass(), EvaluatedData.class);
    List<FieldDictionary> fdList = new ArrayList<FieldDictionary>();
    List<ObjectRelation> foreignList = new ArrayList<ObjectRelation>();
    for (Field f : fields) {
        try {//w  ww  .ja  va 2 s.c  o  m
            Method method = BeanUtils.getReadMethod(ee.getEntityClass(), f);
            Transient t = method.getAnnotation(Transient.class);
            if (t != null) {//????
                logger.warn("??\n " + ee.getName()
                        + "  " + f.getName() + "  Transient ");
                continue;
            }
            Dictinary dictinary = method.getAnnotation(Dictinary.class);
            if (dictinary == null) {//???
                logger.warn("??\n " + ee.getName()
                        + "  " + f.getName() + "  Dictinary ");
                continue;
            }

            FieldDictionary fd = fieldDictionaryDAO.findByObjectAndProperty(od.getId(), f.getName());
            fd = fd == null ? new FieldDictionary() : fd;

            fd.setObjectDictionary(od);//
            fd.setPropertyName(f.getName());//??
            fd.setValid(true);//?
            fd.setDisplayname(dictinary.displayname());//??
            fd.setVisible(dictinary.visible());//???
            fd.setSimpleProperty(BeanUtils.isSimpleTypeField(f));//??

            Column column = method.getAnnotation(Column.class);
            fd.setFieldName(column != null ? column.name() : fd.getPropertyName());//???

            //?
            if (dictinary.foreignKey() != null && dictinary.foreignKey().foreignClass() != Object.class) {
                ForeignKey foreignKey = dictinary.foreignKey();
                ObjectRelation or = new ObjectRelation();
                or.setSelfClass(od.getInstanceClass());
                or.setPropertyName(fd.getPropertyName());
                or.setRelationClass(foreignKey.foreignClass().getName());
                or.setSimpleProperty(fd.isSimpleProperty());
                foreignList.add(or);
            }
            fdList.add(fd);
        } catch (NoSuchMethodException ex) {
            logger.warn("??\n " + ee.getName() + "  "
                    + f.getName() + " read " + ex.getMessage());

        }

    }
    fieldDictionaryDAO.save(fdList);
    objectRelationDAO.save(foreignList);
}

From source file:net.sf.jasperreports.data.xmla.XmlaDataAdapterService.java

@Override
public void test() throws JRException {
    Map<String, Object> params = new HashMap<String, Object>();
    contributeParameters(params);/*  ww w. j a va 2s . c o  m*/

    Properties props = new Properties();
    putNonNull(props, Olap4jXmlaQueryExecuter.XMLA_SERVER,
            params.get(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_URL));
    putNonNull(props, Olap4jXmlaQueryExecuter.XMLA_CATALOG,
            params.get(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG));
    putNonNull(props, Olap4jXmlaQueryExecuter.XMLA_DATA_SOURCE,
            params.get(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE));
    putNonNull(props, Olap4jXmlaQueryExecuter.XMLA_USER,
            params.get(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_USER));
    putNonNull(props, Olap4jXmlaQueryExecuter.XMLA_PASSWORD,
            params.get(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_PASSWORD));
    putNonNull(props, Olap4jXmlaQueryExecuter.OLAP4J_DRIVER, Olap4jXmlaQueryExecuter.OLAP4J_XMLA_DRIVER_CLASS);
    putNonNull(props, Olap4jXmlaQueryExecuter.OLAP4J_URL_PREFIX,
            Olap4jXmlaQueryExecuter.OLAP4J_XMLA_URL_PREFIX);

    try {
        // load driver  and Connection
        Class.forName(Olap4jXmlaQueryExecuter.OLAP4J_XMLA_DRIVER_CLASS);
        Connection connection = DriverManager.getConnection(Olap4jXmlaQueryExecuter.OLAP4J_XMLA_URL_PREFIX,
                props);
        OlapConnection olapConnection = connection.unwrap(OlapConnection.class);

        // doing something to validate the connection
        OlapDatabaseMetaData metaData = olapConnection.getMetaData();
        ResultSet datasources = null;
        try {
            // try olap4j 1.1 first
            Method method = OlapDatabaseMetaData.class.getMethod("getDatabases");
            datasources = (ResultSet) method.invoke(metaData);
        } catch (NoSuchMethodException e) {
            // not olap4j 1.1
            if (log.isDebugEnabled()) {
                log.debug("OlapDatabaseMetaData.getDatabases method not found: " + e.getMessage());
            }
        }

        if (datasources == null) {
            try {
                // try olap4j 0.9
                Method method = OlapDatabaseMetaData.class.getMethod("getDatasources");
                datasources = (ResultSet) method.invoke(metaData);
            } catch (NoSuchMethodException e) {
                // not olap4j 0.9?  giving up
                if (log.isDebugEnabled()) {
                    log.debug("OlapDatabaseMetaData.getDatasources method not found: " + e.getMessage());
                }
            }
        }

        if (datasources != null) {
            // making sure the request is sent
            datasources.next();

            datasources.close();
        }

        connection.close();
    } catch (ClassNotFoundException e) {
        throw new JRException(EXCEPTION_MESSAGE_KEY_XMLA_CONNECTION, null, e);
    } catch (IllegalAccessException e) {
        throw new JRException(EXCEPTION_MESSAGE_KEY_XMLA_CONNECTION, null, e);
    } catch (InvocationTargetException e) {
        throw new JRException(EXCEPTION_MESSAGE_KEY_XMLA_CONNECTION, null, e);
    } catch (SQLException e) {
        throw new JRException(EXCEPTION_MESSAGE_KEY_XMLA_CONNECTION, null, e);
    }

    dispose();
}

From source file:org.apache.camel.maven.JavadocApiMethodGeneratorMojo.java

private String getResultType(Class<?> aClass, String name, String[] types) throws MojoExecutionException {
    Class<?>[] argTypes = new Class<?>[types.length];
    final ClassLoader classLoader = getProjectClassLoader();
    for (int i = 0; i < types.length; i++) {
        try {//w  w  w. j  a  va 2 s.c o  m
            try {
                argTypes[i] = ApiMethodParser.forName(types[i], classLoader);
            } catch (ClassNotFoundException e) {
                throw new MojoExecutionException(e.getMessage(), e);
            }
        } catch (IllegalArgumentException e) {
            throw new MojoExecutionException(e.getCause().getMessage(), e.getCause());
        }
    }

    // return null for non-public methods, and for non-static methods if includeStaticMethods is null or false
    String result = null;
    try {
        final Method method = aClass.getMethod(name, argTypes);
        int modifiers = method.getModifiers();
        if (!Modifier.isStatic(modifiers) || Boolean.TRUE.equals(includeStaticMethods)) {
            result = method.getReturnType().getCanonicalName();
        }
    } catch (NoSuchMethodException e) {
        // could be a non-public method
        try {
            aClass.getDeclaredMethod(name, argTypes);
        } catch (NoSuchMethodException e1) {
            throw new MojoExecutionException(e1.getMessage(), e1);
        }
    }

    return result;
}

From source file:org.atricore.idbus.capabilities.josso.main.binding.JossoSoapBinding.java

public MediationMessage createMessage(CamelMediationMessage message) {

    // Get HTTP Exchange from SAML Exchange
    CamelMediationExchange samlR2exchange = message.getExchange();
    Exchange exchange = samlR2exchange.getExchange();

    logger.debug("Create Message Body from exchange " + exchange.getClass().getName());

    // Converting from CXF Message to SAMLR2 Message
    // Is this a CXF message?
    Message in = exchange.getIn();//  w  ww  .j  a v  a 2  s .c o  m

    if (in.getBody() instanceof MessageContentsList) {

        MessageContentsList mclIn = (MessageContentsList) in.getBody();
        logger.debug("Using CXF Message Content : " + mclIn.get(0));

        StatefulProvider p = null;
        if (getChannel() instanceof StatefulChannel) {
            p = ((StatefulChannel) getChannel()).getProvider();
        }

        MediationState state = null;
        LocalState lState = null;
        if (p != null) {

            if (logger.isDebugEnabled())
                logger.debug(
                        "Attempting to retrieve provider state using JOSSO Backchannel messasge information");

            // Try to recover provider state using alternative sso session id value.
            // This should be a JOSSO Back channel message request (we do not process responses yet)
            Object content = mclIn.get(0);

            if (logger.isTraceEnabled())
                logger.trace("JOSSO Backchannel message " + content);

            if (content != null) {

                String ssoSessionId = null;
                String assertionId = null;

                try {
                    Method getSsoSessionId = content.getClass().getMethod("getSsoSessionId");
                    ssoSessionId = (String) getSsoSessionId.invoke(content);
                } catch (NoSuchMethodException e) {
                    if (logger.isTraceEnabled())
                        logger.trace(e.getMessage());
                } catch (Exception e) {
                    logger.error("Cannot get SSO Session ID from JOSSO backchannel message: " + e.getMessage(),
                            e);
                }

                try {
                    Method getSessionId = content.getClass().getMethod("getSessionId");
                    ssoSessionId = (String) getSessionId.invoke(content);
                } catch (NoSuchMethodException e) {
                    if (logger.isTraceEnabled())
                        logger.trace(e.getMessage());
                } catch (Exception e) {
                    logger.error("Cannot get SSO Session ID from JOSSO backchannel message: " + e.getMessage(),
                            e);
                }

                try {
                    Method getAssertionId = content.getClass().getMethod("getAssertionId");
                    assertionId = (String) getAssertionId.invoke(content);
                } catch (NoSuchMethodException e) {
                    if (logger.isTraceEnabled())
                        logger.trace(e.getMessage());
                } catch (Exception e) {
                    logger.error(
                            "Cannot get SSO Assertion ID from JOSSO backchannel message: " + e.getMessage(), e);
                }

                ProviderStateContext ctx = createProviderStateContext();

                // SSO Session ID is an alternative ID for provider state.
                if (lState == null && ssoSessionId != null) {
                    if (logger.isDebugEnabled())
                        logger.debug(
                                "Attempting to restore provider state based on SSO Session ID " + ssoSessionId);

                    // Add retries just in case we're in a cluster (they are disabled in non HA setups)
                    int retryCount = getRetryCount();
                    if (retryCount > 0) {
                        lState = ctx.retrieve("ssoSessionId", ssoSessionId, retryCount, getRetryDelay());
                    } else {
                        lState = ctx.retrieve("ssoSessionId", ssoSessionId);
                    }
                }

                if (lState == null && assertionId != null) {
                    if (logger.isDebugEnabled())
                        logger.debug(
                                "Attempting to restore provider state based on Assertion ID " + assertionId);
                    // Add retries just in case we're in a cluster (they are disabled in non HA setups)
                    int retryCount = getRetryCount();
                    if (retryCount > 0) {
                        lState = ctx.retrieve("assertionId", assertionId, retryCount, getRetryDelay());
                    } else {
                        lState = ctx.retrieve("assertionId", assertionId);
                    }

                }

            }

        } else {
            logger.warn("No provider found for channel " + channel.getName());
        }

        if (lState == null) {
            // Create a new local state instance ?
            state = createMediationState(exchange);
            lState = state.getLocalState();

            if (logger.isDebugEnabled())
                logger.debug(
                        "Creating new Local State instance " + lState.getId() + " for " + channel.getName());

        } else {

            if (logger.isDebugEnabled())
                logger.debug("Using Local State instance " + lState.getId() + " for " + channel.getName());

            state = new MediationStateImpl(lState);
        }

        return new MediationMessageImpl(in.getMessageId(), mclIn.get(0), null, null, null, state);

    } else {
        throw new IllegalArgumentException("Unknown message type " + in.getBody());
    }

}