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:org.apache.struts.tiles.taglib.PutTag.java

/**
 * Extract real value from specified bean.
 * @throws JspException If something goes wrong while getting value from bean.
 *//*w w w.  j a v a 2 s. c o  m*/
protected void getRealValueFromBean() throws JspException {
    try {
        Object bean = TagUtils.retrieveBean(beanName, beanScope, pageContext);
        if (bean != null && beanProperty != null) {
            realValue = PropertyUtils.getProperty(bean, beanProperty);
        } else {
            realValue = bean; // value can be null
        }

    } catch (NoSuchMethodException ex) {
        throw new JspException("Error - component.PutAttributeTag : Error while retrieving value from bean '"
                + beanName + "' with property '" + beanProperty + "' in scope '" + beanScope
                + "'. (exception : " + ex.getMessage(), ex);

    } catch (InvocationTargetException ex) {
        throw new JspException("Error - component.PutAttributeTag : Error while retrieving value from bean '"
                + beanName + "' with property '" + beanProperty + "' in scope '" + beanScope
                + "'. (exception : " + ex.getMessage(), ex);

    } catch (IllegalAccessException ex) {
        throw new JspException("Error - component.PutAttributeTag : Error while retrieving value from bean '"
                + beanName + "' with property '" + beanProperty + "' in scope '" + beanScope
                + "'. (exception : " + ex.getMessage(), ex);
    }
}

From source file:com.snaplogic.snaps.firstdata.Create.java

private Object getTypesInstance(String classType, String value) {
    Method method = null;//ww w.j ava  2 s .  c om
    try {
        Class<?> types = getClassType(classType);
        method = types.getMethod(TYPES_METHOD, String.class);
        Object typesObj = method.invoke(null, value);
        return typesObj;
    } catch (NoSuchMethodException e) {
        log.error(e.getMessage(), e);
        writeToErrorView(NOSUCH_METHOD_EXE, e.getMessage(), ERROR_RESOLUTION, e);
    } catch (SecurityException e) {
        log.error(e.getMessage(), e);
        writeToErrorView(SECURITY_EXE, e.getMessage(), SECURITY_EXE_RES, e);
    } catch (IllegalArgumentException e) {
        log.error(e.getMessage(), e);
        writeToErrorView(String.format(ILLEGAL_ARGS_EXE, method.getName()), e.getMessage(), ERROR_RESOLUTION,
                e);
    } catch (InvocationTargetException e) {
        log.error(e.getMessage(), e);
        writeToErrorView(e.getTargetException().getMessage(), e.getMessage(), ERROR_RESOLUTION, e);
    } catch (IllegalAccessException e) {
        log.error(e.getMessage(), e);
        writeToErrorView(String.format(ILLIGAL_ACCESS_EXE, method.getName()), e.getMessage(),
                ILLIGAL_ACCESS_EXE_RES, e);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        writeToErrorView(ERRORMSG, e.getMessage(), ERROR_RESOLUTION, e);
    }
    return null;
}

From source file:org.atricore.idbus.idojos.memoryidentitystore.MemoryIdentityStore.java

protected String getTextContent(Node node) {
    try {//from  w w w . j a  v  a  2s.c  om
        // Only supported in earlier versions of DOM
        Method getTextContent = node.getClass().getMethod("getTextContent");
        return (String) getTextContent.invoke(node);

    } catch (NoSuchMethodException e) {
        logger.debug("Using old DOM Java Api to get Node text content");
    } catch (InvocationTargetException e) {
        logger.warn(e.getMessage(), e);
    } catch (IllegalAccessException e) {
        logger.warn(e.getMessage(), e);
    }

    // Old DOM API usage to get node's text content
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        if (child.getNodeType() == Node.TEXT_NODE) {
            return child.getNodeValue();
        }
    }
    return null;
}

From source file:com.aliyun.fs.oss.utils.OSSClientAgent.java

@SuppressWarnings("unchecked")
private ObjectMetadata getObjectMetadata(String bucket, String key, boolean retry)
        throws IOException, ServiceException, ClientException {
    try {//  ww w  .j a v  a  2s.  c  om
        GsonBuilder builder = new GsonBuilder();
        builder.registerTypeAdapter(ObjectMetadata.class, new ObjectMetadataDeserializer());
        Gson gson = builder.create();

        Method method = this.ossClientClz.getMethod("getObjectMetadata", String.class, String.class);
        Object ret = method.invoke(this.ossClient, bucket, key);
        return gson.fromJson(gson.toJson(ret), ObjectMetadata.class);
    } catch (NoSuchMethodException e) {
        LOG.error(e.getMessage());
        return null;
    } catch (Exception e) {
        if (retry && updateOSSClient(e)) {
            return getObjectMetadata(bucket, key, false);
        } else {
            handleException(e);
            return null;
        }
    }
}

From source file:org.springmodules.xt.model.generator.factory.FactoryGeneratorInterceptor.java

private Object make() {
    logger.debug("Making object of class: " + this.productClass);

    int argsNr = this.constructorArgs.size();
    Object[] argsArray = new Object[argsNr];
    Class[] typesArray = new Class[argsNr];
    for (Map.Entry<Integer, ConstructorArgPair> entry : this.constructorArgs.entrySet()) {
        int position = entry.getKey();
        Object value = entry.getValue().getValue();
        Class type = entry.getValue().getType();
        if (position < 0 || position > argsNr - 1) {
            throw new IllegalArgumentPositionException("Illegal position: " + position);
        } else {// w  w  w. ja va2  s.  c  o  m
            argsArray[position] = value;
            typesArray[position] = type;
        }
    }

    try {
        Constructor constructor = this.productClass.getConstructor(typesArray);
        Object product = constructor.newInstance(argsArray);
        return product;
    } catch (NoSuchMethodException ex) {
        throw new ObjectConstructionException("No constructor found accepting the following array of types: "
                + ToStringBuilder.reflectionToString(typesArray, ToStringStyle.SIMPLE_STYLE)
                + " Have you correctly set all constructor arguments?", ex);
    } catch (InvocationTargetException ex) {
        throw new ObjectConstructionException(
                "Exception thrown by the underlying constructor: " + ex.getMessage(), ex);
    } catch (IllegalAccessException ex) {
        throw new ObjectConstructionException("Cannot access a constructor with the following array of types: "
                + ToStringBuilder.reflectionToString(typesArray, ToStringStyle.SIMPLE_STYLE)
                + " Have you correctly set all constructor arguments?", ex);
    } catch (InstantiationException ex) {
        throw new ObjectConstructionException("Unable to instantiate the following class: " + this.productClass,
                ex);
    }
}

From source file:org.o3project.odenos.remoteobject.RemoteObjectManager.java

protected Response createRemoteObject(final String id, final ObjectProperty prop) {
    if (prop == null) {
        return new Response(Response.BAD_REQUEST, "Bad format: ObjectProperty is expected");
    }/*from  www  .  jav  a 2  s .c  o  m*/

    if (!classList.containsKey(prop.getObjectType())) {
        return new Response(Response.BAD_REQUEST, "Error unknown type ");
    }

    if (objects.containsKey(id)) {
        return new Response(Response.CONFLICT, "the RemoteObject is already created");
    }
    prop.setProperty(ObjectProperty.PropertyNames.OBJECT_ID, id);

    RemoteObject object = null;
    try {
        Class<? extends RemoteObject> clazz = classList.get(prop.getObjectType());
        try {
            Constructor<? extends RemoteObject> constructor = clazz.getConstructor(String.class,
                    MessageDispatcher.class);
            object = constructor.newInstance(id, this.getMessageDispatcher());
        } catch (NoSuchMethodException e) {
            Constructor<? extends RemoteObject> constructor = clazz.getConstructor(String.class, String.class,
                    MessageDispatcher.class);
            object = constructor.newInstance(id, objectProperty.getBaseUri(), this.getMessageDispatcher());
        }
        objects.put(id, object);
        if (object.onInitialize(prop)) {
            object.setState(ObjectProperty.State.RUNNING);
        } else {
            object.setState(ObjectProperty.State.ERROR);
        }
    } catch (Exception e) {
        return new Response(Response.INTERNAL_SERVER_ERROR, e.getMessage());
    }
    return new Response(Response.CREATED, object.getProperty());
}

From source file:org.dspace.rest.providers.AbstractBaseProvider.java

public Object getEntity(EntityReference ref, String action) {

    if (action.lastIndexOf(".") > 0) {
        action = action.substring(0, action.lastIndexOf("."));
    }/* ww w .  ja v  a  2 s. c  o  m*/

    if (func2actionMapGET_rev.containsKey(action)) {
        Object result;
        String function = getMethod(action, func2actionMapGET_rev);
        if (function == null) {
            throw new EntityException("Bad request", "Method not supported - not defined", 400);
        }

        Context context = null;
        try {
            context = new Context();
            UserRequestParams uparams = refreshParams(context);

            Object CE = entityConstructor.newInstance();
            Method method = CE.getClass().getMethod(function, funcParamsGET.get(action));
            result = method.invoke(CE, ref, uparams, context);
        } catch (NoSuchMethodException ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Not found", "Method not supported ", 404);
        } catch (SQLException ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (InvocationTargetException ex) {
            if (ex.getCause() != null) {
                log.error(ex.getCause(), ex.getCause());
                throw new EntityException(ex.getCause().toString(), "Invocation Target Exception", 500);
            } else {
                log.error(ex.getMessage(), ex);
                throw new EntityException("Internal server error", "Unknown error", 500);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Internal server error", "Unknown error", 500);
        } finally {
            removeConn(context);
        }
        return result;
    } else {
        throw new EntityException("Bad request", "Method not supported " + action, 400);
    }
}

From source file:com.surveypanel.form.Form.java

/**
 * Process the given FormData object.  The FormData object will first be validated and then stored in the target
 * object by invoking the setXXX method for the given field.
 *
 * @param formData The FormData object//from ww  w.  j  a v a  2  s  . com
 * @return The ValidationResult
 * @throws Exception Any exception
 */
protected ValidationResult process(QuestionImpl question, FormData formData, Locale locale) throws Exception {
    String name = question.getName();

    if (log.isDebugEnabled())
        log.debug("Validating field " + name);

    ValidationResult validationResult = validate(question, formData);
    validations.put(name, validationResult);
    log.debug("Validation complete.");

    // the current process is that only form data with a
    // defined form element will be written to the target
    // object...the other possible behavior is to process
    // store and convert for each FormData object -AE
    Object value = formData.getValue();
    try {
        if (value != null) {
            value = convert(question, value, locale);
        }
    } catch (NoSuchMethodException e) {
        log.info("No method found for parameter " + name);
    } catch (Exception e) {
        log.error("Error writing field " + name + ":" + e.getMessage());
    }

    return validationResult;
}

From source file:org.dspace.rest.providers.AbstractBaseProvider.java

public void updateEntity(EntityReference ref, Object entity, Map<String, Object> params) {
    Map<String, Object> inputVar = (HashMap<String, Object>) entity;
    String segments[] = getSegments(params);

    String action = "";
    if (segments.length > 3) {
        action = segments[3];//from  w  w w  .ja  va  2  s  . c  om
        if (action.lastIndexOf(".") > 0) {
            action = action.substring(0, action.lastIndexOf("."));
        }
    }

    if (func2actionMapPUT_rev.containsKey(action)) {
        String function = getMethod(action, func2actionMapPUT_rev);
        if (function == null) {
            throw new EntityException("Bad request", "Method not supported - not defined", 400);
        }

        Context context = null;
        try {
            context = new Context();
            refreshParams(context);

            Object CE = entityConstructor.newInstance();
            Method method = CE.getClass().getMethod(function, funcParamsPUT.get(action));
            method.invoke(CE, ref, inputVar, context);
        } catch (NoSuchMethodException ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Not found", "Meethod not supported " + segments[3], 404);
        } catch (SQLException ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (InvocationTargetException ex) {
            if (ex.getCause() != null) {
                log.error(ex.getCause(), ex.getCause());
                throw new EntityException(ex.getCause().toString(), "Invocation Target Exception", 500);
            } else {
                log.error(ex.getMessage(), ex);
                throw new EntityException("Internal server error", "Unknown error", 500);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Internal server error", "Unknown error", 500);
        } finally {
            removeConn(context);
        }
    } else {
        throw new EntityException("Bad request", "Maethod not supported " + action, 400);
    }
}

From source file:org.dspace.rest.providers.AbstractBaseProvider.java

public String createEntity(EntityReference ref, Object entity, Map<String, Object> params) {
    String result;// w  w  w . j a v a2 s.co  m
    Map<String, Object> inputVar = new HashMap<String, Object>();
    if (entity instanceof Map) {
        inputVar = (HashMap<String, Object>) entity;
    }

    String function;
    String[] mandatory_params;

    String action = "";
    String segments[] = getSegments(params);
    if (segments.length > 2) {
        action = segments[segments.length - 1];
        if (action.lastIndexOf(".") > 0) {
            action = action.substring(0, action.lastIndexOf("."));
        }
    }

    if (func2actionMapPOST_rev.containsKey(action)) {
        function = func2actionMapPOST_rev.get(action);
        if (function == null) {
            throw new EntityException("Bad request", "Method not supported - not defined", 400);
        }
        mandatory_params = inputParamsPOST.get(function);
        if (mandatory_params != null) {
            for (String param : mandatory_params) {
                if (inputVar.get(param) == null) {
                    throw new EntityException("Bad request", "Incomplete request [mandatory param]", 400);
                }
            }
        }

        Context context = null;
        try {
            context = new Context();
            refreshParams(context);

            Object CE = entityConstructor.newInstance();
            Method method = CE.getClass().getMethod(function, funcParamsPOST.get(action));
            if (entity instanceof Map) {
                result = (String) method.invoke(CE, ref, inputVar, context);
            } else {
                result = (String) method.invoke(CE, ref, entity, context);
            }
        } catch (NoSuchMethodException ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Not found", "Method not supported ", 404);
        } catch (SQLException ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (InvocationTargetException ex) {
            if (ex.getCause() != null) {
                log.error(ex.getCause(), ex.getCause());
                throw new EntityException(ex.getCause().toString(), "Invocation Target Exception", 500);
            } else {
                log.error(ex.getMessage(), ex);
                throw new EntityException("Internal server error", "Unknown error", 500);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            throw new EntityException("Internal server error", "Unknown error", 500);
        } finally {
            removeConn(context);
        }
        return result;
    } else {
        throw new EntityException("Bad request", "Method not supported " + action, 400);
    }
}