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:dk.netarkivet.externalsoftware.HeritrixTests.java

/**
 * Get a list of URLs as calculated by the Heritrix tests.
 *
 * @return The list of URLs.//from w w  w.  ja  va 2  s  .c o m
 */
private URL[] classPathAsURLS() {
    URL[] urls = null;
    try {
        Method method = ReflectUtils.getPrivateMethod(AbstractJMXHeritrixController.class, "updateEnvironment",
                Map.class);
        Map<String, String> environment = new HashMap<String, String>(System.getenv());
        method.invoke(null, environment);
        String[] urlStrings = environment.get("CLASSPATH").split(":");
        urls = new URL[urlStrings.length];
        for (int i = 0; i < urlStrings.length; i++) {
            urls[i] = new URL("file:" + urlStrings[i]);
        }
    } catch (NoSuchMethodException e) {
        e.printStackTrace(System.err);
        fail("Exception " + e.getMessage());
    } catch (IllegalAccessException e) {
        e.printStackTrace(System.err);
        fail("Exception " + e.getMessage());
    } catch (InvocationTargetException e) {
        e.printStackTrace(System.err);
        fail("Exception " + e.getMessage());
    } catch (MalformedURLException e) {
        e.printStackTrace(System.err);
        fail("Exception " + e.getMessage());
    }
    return urls;
}

From source file:com.msopentech.o365.outlookServices.OutlookServicesProxy.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    Method handler;//w w  w  .  ja  va  2  s.c om
    try {
        // Get appropriate method for handling provided action
        handler = OutlookServicesMethodsImpl.class.getDeclaredMethod(action, CallbackContext.class,
                OutlookClient.class, DefaultDependencyResolver.class, ODataMethodArgs.class);
    } catch (NoSuchMethodException e) {
        // If no appropriate method found, send return false to indicate this
        return false;
    }

    // parse arguments passed from JS layer to ArrayList objects
    ODataMethodArgs methodArgs = ODataMethodArgs.parseInvocationArgs(args);

    //Get common parameters necessary for creating OutlookClient object
    //and create a new one or use an existing if token and serviceRoot are unchanged from previous call
    final String token = methodArgs.getToken();
    final String serviceRoot = methodArgs.getServiceRoot();
    OutlookClient client = getClient(serviceRoot, token);

    try {
        // If appropriate method found, invoke it with arguments parsed from action args
        handler.invoke(null, callbackContext, client, this.resolver, methodArgs);
    } catch (InvocationTargetException e) {
        // Catch inner method's exception and send back an error result
        String message = "Method " + action + " failed with error: " + e.getMessage();
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, message));
    } catch (IllegalAccessException e) {
        // Catch method invocation exception and send back an error result
        String message = "Failed to call native method " + action + ": " + e.getMessage();
        callbackContext
                .sendPluginResult(new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION, message));
    }

    // Return true here to indicate that action is handled by plugin
    return true;
}

From source file:com.odoo.core.orm.OModel.java

private Method checkForOnChangeMethod(Field field) {
    Annotation annotation = field.getAnnotation(Odoo.onChange.class);
    if (annotation != null) {
        Odoo.onChange onChange = (Odoo.onChange) annotation;
        String method_name = onChange.method();
        try {//  ww w . j av a  2 s.c  o  m
            return getClass().getMethod(method_name, ODataRow.class);
        } catch (NoSuchMethodException e) {
            Log.e(TAG, "No Such Method: " + e.getMessage());
        }
    }
    return null;
}

From source file:com.odoo.core.orm.OModel.java

private Method checkForFunctionalColumn(Field field) {
    Annotation annotation = field.getAnnotation(Odoo.Functional.class);
    if (annotation != null) {
        Odoo.Functional functional = (Odoo.Functional) annotation;
        String method_name = functional.method();
        try {/*  w ww  .  j  av a2 s  . co  m*/
            if (functional.store())
                return getClass().getMethod(method_name, OValues.class);
            else
                return getClass().getMethod(method_name, ODataRow.class);
        } catch (NoSuchMethodException e) {
            Log.e(TAG, "No Such Method: " + e.getMessage());
        }
    }
    return null;
}

From source file:org.saiku.adhoc.service.SaikuAdhocContentGenerator.java

@Override
public void createContent(OutputStream out) throws Exception {
    {//w w w .  j  a  v  a 2s. c  om

        final IParameterProvider pathParams = parameterProviders.get("path");
        final IParameterProvider requestParams = parameterProviders.get("request");

        try {

            final Class[] params = { IParameterProvider.class, OutputStream.class };

            final String method = pathParams.getStringParameter("path", null).split("/")[1].toLowerCase();

            try {
                final Method mthd = this.getClass().getMethod(method, params);
                mthd.invoke(this, requestParams, out);
            } catch (NoSuchMethodException e) {
                logger.error("could not invoke " + method);
            } catch (InvocationTargetException e) {
                //get to the cause and rethrow properly
                Throwable target = e.getTargetException();
                if (!e.equals(target)) {//just in case
                                        //get to the real cause
                    while (target != null && target instanceof InvocationTargetException) {
                        target = ((InvocationTargetException) target).getTargetException();
                    }
                }
                if (target instanceof Exception) {
                    throw (Exception) target;
                } else {
                    throw new Exception(target);
                }
            }
        } catch (Exception e) {
            final String message = e.getCause() != null
                    ? e.getCause().getClass().getName() + " - " + e.getCause().getMessage()
                    : e.getClass().getName() + " - " + e.getMessage();
            logger.error(message, e);
        }
    }
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static void overridePendingTransition(final Activity activity) {
    if (overridePendingTransition == null) {
        try {//  w  w w  .  j  av  a2 s. c  o  m
            overridePendingTransition = Activity.class.getMethod("overridePendingTransition", Integer.TYPE,
                    Integer.TYPE);
        } catch (NoSuchMethodException e) {
            Log.w(TAG, "Activity.overridePendingTransition() not found");
        }

    }

    if (overridePendingTransition != null) {
        try {
            overridePendingTransition.invoke(activity, new Object[] { 0, 0 });
        } catch (InvocationTargetException e) {
            Log.e(TAG, "Called incorrectly: " + e.getMessage());
        } catch (IllegalAccessException e) {
            Log.e(TAG, "Illegal access: " + e.getMessage());
        }
    }
}

From source file:nl.toolforge.karma.core.cmd.CommandFactory.java

private Command getCommand(String commandName, String[] arguments) throws CommandException {

    Command cmd = null;/*from  www  . j a va  2s . com*/

    if (isCommand(commandName)) {

        CommandDescriptor descriptor = null;
        try {
            descriptor = getCommandDescriptor(commandName);

            // Construct the command implementation, with the default constructor
            //
            Class implementingClass = null;
            try {
                implementingClass = Class.forName(descriptor.getClassName());
            } catch (ClassNotFoundException c) {
                throw new CommandException(CommandException.NO_IMPLEMENTING_CLASS,
                        new Object[] { descriptor.getClassName() });
            }

            Constructor defaultConstructor = implementingClass
                    .getConstructor(new Class[] { CommandDescriptor.class });
            cmd = (Command) defaultConstructor.newInstance(new Object[] { descriptor });

            // Parse the command line options.
            //
            CommandLineParser parser = new PosixParser();

            Options parserOptions = descriptor.getOptions();

            //        if (parserOptions.getOptions().size() == 0 && arguments.length > 0) {
            //          // The issue is that this is 1. not an exception and 2. no mechanism to propagate this back in a nice way.
            //          throw new CommandException(CommandException.NO_OPTIONS_REQUIRED);
            //        }

            cmd.setCommandLine(parser.parse(parserOptions, arguments));

        } catch (NoSuchMethodException e) {
            throw new KarmaRuntimeException(e.getLocalizedMessage(), e);
        } catch (SecurityException e) {
            throw new KarmaRuntimeException(e.getLocalizedMessage(), e);
        } catch (InstantiationException e) {
            throw new KarmaRuntimeException(e.getLocalizedMessage(), e);
        } catch (IllegalAccessException e) {
            throw new KarmaRuntimeException(e.getLocalizedMessage(), e);
        } catch (IllegalArgumentException e) {
            throw new KarmaRuntimeException(e.getLocalizedMessage(), e);
        } catch (InvocationTargetException e) {
            throw new KarmaRuntimeException(e.getLocalizedMessage(), e);
        } catch (ParseException e) {
            if (e instanceof MissingOptionException) {
                throw new CommandException(e, CommandException.MISSING_OPTION, new Object[] { e.getMessage() });
            }
            if (e instanceof UnrecognizedOptionException) {
                throw new CommandException(e, CommandException.INVALID_OPTION, new Object[] { arguments });
            }
            if (e instanceof MissingArgumentException) {
                throw new CommandException(e, CommandException.MISSING_ARGUMENT,
                        new Object[] { e.getMessage() });
            }
        }
        return cmd;
    }
    // At this point, we have no command
    //
    throw new CommandException(CommandException.UNKNOWN_COMMAND, new Object[] { commandName });
}

From source file:net.firejack.platform.core.utils.Factory.java

private Object get(Object bean, String name, Class valueType) {
    try {//from   w ww  . j  ava2  s .  c  o  m
        Object value;
        try {
            value = getInstance().getProperty(bean, name);
        } catch (NoSuchMethodException e) {
            value = getInstance().getProperty(bean, fixPath(name));
        } catch (Exception e) {
            value = null;
        }

        if (!Hibernate.isInitialized(value))
            value = null;

        if (value != null && valueType != null && value.getClass() != valueType) {
            XmlAdapter adapter = adapters.get(valueType.getName() + value.getClass().getName());
            if (adapter != null)
                try {
                    return adapter.marshal(value);
                } catch (ClassCastException e) {
                    return adapter.unmarshal(value);
                }
        }

        return value;
    } catch (Exception e) {
        logger.warn(e.getMessage());
    }
    return null;
}

From source file:cn.powerdash.libsystem.common.exception.AbstractExceptionHandler.java

private String getJsonNameFromMethod(final Field errorField, Class<?> dtoClass) {
    /** find annotation from get/set method........ **/
    String methodName = "set" + errorField.getName().substring(0, 1).toUpperCase()
            + errorField.getName().substring(1);
    try {//w ww . j a va  2  s  .  com
        Method method = dtoClass.getDeclaredMethod(methodName, errorField.getType());
        method.setAccessible(true);
        JsonProperty jsonProperty2 = method.getAnnotation(JsonProperty.class);
        if (jsonProperty2 != null) {
            String jp = jsonProperty2.value();
            LOGGER.debug("JsonProperty from SetMethod ===== " + jp);
            return jp;
        }
    } catch (NoSuchMethodException e) {
        LOGGER.debug("NoSuchMethodException {}, try to get JsonProperty from super class", methodName);
        try {
            /**
             * Get JsonProperty from super class. It is only a simple implementation base on one assumption that
             * super class should exist this field. It does not process recursion.
             * **/
            Method method = dtoClass.getSuperclass().getDeclaredMethod(methodName, errorField.getType());
            method.setAccessible(true);
            JsonProperty jsonProperty2 = method.getAnnotation(JsonProperty.class);
            if (jsonProperty2 != null) {
                String jp = jsonProperty2.value();
                LOGGER.debug("JsonProperty from Super {} `s SetMethod ===== {} ", dtoClass.getSuperclass(), jp);
                return jp;
            }
        } catch (Exception ex) { // NOSONAR
            LOGGER.debug(e.getMessage());
        }
    } catch (SecurityException e) {
        LOGGER.debug(e.getMessage());
    }
    return null;
}

From source file:jef.tools.reflect.ClassEx.java

Object innerInvoke(Object obj, String method, boolean isStatic, Object... params) throws ReflectionException {
    try {/*from  w w  w  . j  a va  2s  .c o m*/
        if (obj == null && !isStatic)
            obj = newInstance();
        List<Class<?>> list = new ArrayList<Class<?>>();
        for (Object pobj : params) {
            list.add(pobj.getClass());
        }
        MethodEx me = BeanUtils.getCompatibleMethod(cls, method, list.toArray(new Class[list.size()]));
        if (me == null) {
            NoSuchMethodException e = new NoSuchMethodException("Method:[" + cls.getName() + "::" + method
                    + "] not found with param count:" + params.length);
            throw new ReflectionException(e);
        }
        if (!Modifier.isPublic(me.getModifiers()) || !Modifier.isPublic(cls.getModifiers())) {
            try {
                me.setAccessible(true);
            } catch (SecurityException e) {
                System.out.println(me.toString() + "\n" + e.getMessage());
            }
        }
        return me.invoke(obj, params);
    } catch (IllegalAccessException e) {
        throw new ReflectionException(e);
    } catch (SecurityException e) {
        throw new ReflectionException(e);
    } catch (IllegalArgumentException e) {
        throw new ReflectionException(e);
    } catch (InvocationTargetException e) {
        if (e.getCause() instanceof Exception) {
            throw new ReflectionException((Exception) e.getCause());
        } else {
            throw new ReflectionException(e);
        }

    }
}