Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.clustercontrol.sql.factory.RunMonitorSql.java

/**
 * SQL?//from   www  .  jav a  2  s. c o  m
 * 
 * @param facilityId ID
 * @return ???????true
 */
@Override
public boolean collect(String facilityId) {
    // set Generation Date
    if (m_now != null) {
        m_nodeDate = m_now.getTime();
    }

    boolean result = false;

    AccessDB access = null;
    ResultSet rSet = null;

    String url = m_url;

    try {
        // ???URL??
        if (nodeInfo != null && nodeInfo.containsKey(facilityId)) {
            Map<String, String> nodeParameter = RepositoryUtil.createNodeParameter(nodeInfo.get(facilityId));
            StringBinder strbinder = new StringBinder(nodeParameter);
            url = strbinder.bindParam(m_url);
            if (m_log.isTraceEnabled())
                m_log.trace("jdbc request. (nodeInfo = " + nodeInfo + ", facilityId = " + facilityId
                        + ", url = " + url + ")");
        }

        // DB??
        access = new AccessDB(m_jdbcDriver, url, m_user, m_password);

        // SQL?????
        if (m_query.length() >= 6) {
            String work = m_query.substring(0, 6);
            if (work.equalsIgnoreCase("SELECT")) {
                rSet = access.read(m_query);

                //1?1??
                rSet.first();
                double count = rSet.getDouble(1);
                m_value = count;

                //?
                rSet.last();
                int number = rSet.getRow();

                NumberFormat numberFormat = NumberFormat.getNumberInstance();
                m_message = MessageConstant.SELECT_VALUE.getMessage() + " : " + m_value;
                m_messageOrg = MessageConstant.RECORD_VALUE.getMessage() + " : " + numberFormat.format(m_value)
                        + ", " + MessageConstant.RECORDS_NUMBER.getMessage() + " : "
                        + numberFormat.format(number);
                m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url;

                result = true;
            } else {
                //SELECT?
                m_log.info("collect(): "
                        + MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage());
                m_unKnownMessage = MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage();
                m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query;
                m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url;
            }
        } else {
            //SELECT?
            m_log.info("collect(): " + MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage());
            m_unKnownMessage = MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage();
            m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query;
            m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url;
        }
    } catch (ClassNotFoundException e) {
        m_log.debug("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        m_unKnownMessage = MessageConstant.MESSAGE_CANNOT_FIND_JDBC_DRIVER.getMessage();
        m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query + " (" + e.getMessage() + ")";
        m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url;
    } catch (SQLException e) {
        // SQL
        m_log.info("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        m_unKnownMessage = MessageConstant.MESSAGE_FAILED_TO_EXECUTE_SQL.getMessage();
        m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query + " (" + e.getMessage() + ")";
        m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url;
    } finally {
        try {
            if (rSet != null) {
                rSet.close();
            }
            if (access != null) {
                // DB?
                access.terminate();
            }
        } catch (SQLException e) {
            m_log.warn("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        }
    }
    return result;
}

From source file:com.snaplogic.snaps.uniteller.BaseService.java

@Override
public void defineInputSchema(SchemaProvider provider) {
    Class<?> classType = null;
    try {// ww w .  j  av a2 s. c o  m
        classType = Class.forName(getUFSReqClassType());
    } catch (ClassNotFoundException e) {
        log.error(e.getMessage(), e);
    }
    for (String viewName : provider.getRegisteredViewNames()) {
        SchemaBuilder schemaBuilder = provider.getSchemaBuilder(viewName);
        for (Method method : findSetters(classType)) {
            schemaBuilder.withChildSchema(
                    provider.createSchema(util.getDataTypes(method), method.getName().substring(3)));
        }
        schemaBuilder.build();
    }
}

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

public Class<?> getProxyType() throws MojoExecutionException {
    if (proxyType == null) {
        // load proxy class from Project runtime dependencies
        try {/*from ww w.  j av  a  2s .  c o m*/
            proxyType = getProjectClassLoader().loadClass(proxyClass);
        } catch (ClassNotFoundException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }
    return proxyType;
}

From source file:org.apache.hadoop.hive.ql.exec.spark.SparkPlanGenerator.java

@SuppressWarnings({ "unchecked" })
private JobConf cloneJobConf(BaseWork work) throws Exception {
    if (workToJobConf.containsKey(work)) {
        return workToJobConf.get(work);
    }/*from  w w  w.  jav  a 2s.  c o  m*/
    JobConf cloned = new JobConf(jobConf);
    // Make sure we'll use a different plan path from the original one
    HiveConf.setVar(cloned, HiveConf.ConfVars.PLAN, "");
    try {
        cloned.setPartitionerClass((Class<? extends Partitioner>) JavaUtils
                .loadClass(HiveConf.getVar(cloned, HiveConf.ConfVars.HIVEPARTITIONER)));
    } catch (ClassNotFoundException e) {
        String msg = "Could not find partitioner class: " + e.getMessage() + " which is specified by: "
                + HiveConf.ConfVars.HIVEPARTITIONER.varname;
        throw new IllegalArgumentException(msg, e);
    }
    if (work instanceof MapWork) {
        cloned.setBoolean("mapred.task.is.map", true);
        List<Path> inputPaths = Utilities.getInputPaths(cloned, (MapWork) work, scratchDir, context, false);
        Utilities.setInputPaths(cloned, inputPaths);
        Utilities.setMapWork(cloned, (MapWork) work, scratchDir, false);
        Utilities.createTmpDirs(cloned, (MapWork) work);
        if (work instanceof MergeFileWork) {
            MergeFileWork mergeFileWork = (MergeFileWork) work;
            cloned.set(Utilities.MAPRED_MAPPER_CLASS, MergeFileMapper.class.getName());
            cloned.set("mapred.input.format.class", mergeFileWork.getInputformat());
            cloned.setClass("mapred.output.format.class", MergeFileOutputFormat.class, FileOutputFormat.class);
        } else {
            cloned.set(Utilities.MAPRED_MAPPER_CLASS, ExecMapper.class.getName());
        }
        if (((MapWork) work).getMinSplitSize() != null) {
            HiveConf.setLongVar(cloned, HiveConf.ConfVars.MAPREDMINSPLITSIZE,
                    ((MapWork) work).getMinSplitSize());
        }
        // remember the JobConf cloned for each MapWork, so we won't clone for it again
        workToJobConf.put(work, cloned);
    } else if (work instanceof ReduceWork) {
        cloned.setBoolean("mapred.task.is.map", false);
        Utilities.setReduceWork(cloned, (ReduceWork) work, scratchDir, false);
        Utilities.createTmpDirs(cloned, (ReduceWork) work);
        cloned.set(Utilities.MAPRED_REDUCER_CLASS, ExecReducer.class.getName());
    }
    return cloned;
}

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.java 2s .c  om
            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:com.phonegap.api.PluginManagerFunction.java

/**
 * The invoke method is called when phonegap.pluginManager.exec(...) is  
 * used from the script environment.  It instantiates the appropriate plugin
 * and invokes the specified action.  JavaScript arguments are passed in 
 * as an array of objects./*from ww  w . java2s  .c om*/
 * 
   * @param service       String containing the service to run
 * @param action       String containing the action that the service is supposed to perform. This is
 *                   passed to the plugin execute method and it is up to the plugin developer 
 *                   how to deal with it.
 * @param callbackId    String containing the id of the callback that is executed in JavaScript if
 *                   this is an async plugin call.
 * @param args          An Array literal string containing any arguments needed in the
 *                   plugin execute method.
 * @param async       Boolean indicating whether the calling JavaScript code is expecting an
 *                   immediate return value. If true, either PhoneGap.callbackSuccess(...) or 
 *                   PhoneGap.callbackError(...) is called once the plugin code has executed.
 * 
 * @return             JSON encoded string with a response message and status.
 * 
 * @see net.rim.device.api.script.ScriptableFunction#invoke(java.lang.Object, java.lang.Object[])
 */
public Object invoke(Object obj, Object[] oargs) throws Exception {
    final String service = (String) oargs[ARG_SERVICE];
    final String action = (String) oargs[ARG_ACTION];
    final String callbackId = (String) oargs[ARG_CALLBACK_ID];
    boolean async = (oargs[ARG_ASYNC].toString().equals("true") ? true : false);
    PluginResult pr = null;

    try {
        // action arguments
        final JSONArray args = new JSONArray((String) oargs[ARG_ARGS]);

        // get the class for the specified service
        String clazz = this.pluginManager.getClassForService(service);
        Class c = null;
        if (clazz != null) {
            c = getClassByName(clazz);
        }

        if (isPhoneGapPlugin(c)) {
            // Create a new instance of the plugin and set the context
            final Plugin plugin = this.addPlugin(clazz, c);
            async = async && !plugin.isSynch(action);
            if (async) {
                // Run this async on a background thread so that JavaScript can continue on
                Thread thread = new Thread(new Runnable() {
                    public void run() {
                        // Call execute on the plugin so that it can do it's thing
                        final PluginResult result = plugin.execute(action, args, callbackId);

                        if (result != null) {
                            int status = result.getStatus();

                            // If plugin status is OK, 
                            // or plugin is not going to send an immediate result (NO_RESULT) 
                            if (status == PluginResult.Status.OK.ordinal()
                                    || status == PluginResult.Status.NO_RESULT.ordinal()) {
                                PhoneGapExtension.invokeSuccessCallback(callbackId, result);
                            }
                            // error
                            else {
                                PhoneGapExtension.invokeErrorCallback(callbackId, result);
                            }
                        }
                    }
                });
                thread.start();
                return "";
            } else {
                // Call execute on the plugin so that it can do it's thing
                pr = plugin.execute(action, args, callbackId);
            }
        }
    } catch (ClassNotFoundException e) {
        pr = new PluginResult(PluginResult.Status.CLASSNOTFOUNDEXCEPTION,
                "ClassNotFoundException: " + e.getMessage());
    } catch (IllegalAccessException e) {
        pr = new PluginResult(PluginResult.Status.ILLEGALACCESSEXCEPTION,
                "IllegalAccessException:" + e.getMessage());
    } catch (InstantiationException e) {
        pr = new PluginResult(PluginResult.Status.INSTANTIATIONEXCEPTION,
                "InstantiationException: " + e.getMessage());
    } catch (JSONException e) {
        pr = new PluginResult(PluginResult.Status.JSONEXCEPTION, "JSONException: " + e.getMessage());
    }
    // if async we have already returned at this point unless there was an error...
    if (async) {
        PhoneGapExtension.invokeErrorCallback(callbackId, pr);
    }
    return (pr != null ? pr.getJSONString() : "{ status: 0, message: 'all good' }");
}

From source file:org.apache.synapse.core.axis2.SynapseModule.java

private static SynapseConfiguration initializeSynapse(ConfigurationContext cfgCtx) {

    AxisConfiguration axisConfiguration = cfgCtx.getAxisConfiguration();

    /*//  www.  j  a v a2s.  c  o m
    First check, if synapse.xml URL is provided as a system property, if so use it..
    else check if synapse.xml location is available from the axis2.xml
    "SynapseConfiguration" else use the default config
    */
    SynapseConfiguration synapseConfiguration;
    Parameter configParam = axisConfiguration.getParameter(Constants.SYNAPSE_CONFIGURATION);

    String config = System.getProperty(Constants.SYNAPSE_XML);

    if (config != null) {
        log.info(
                "System property '" + Constants.SYNAPSE_XML + "' specifies synapse configuration as " + config);
        synapseConfiguration = SynapseConfigurationBuilder.getConfiguration(config);
    } else if (configParam != null) {
        log.info("Synapse configuration is available via the "
                + "'SynapseConfiguration' parameter in axis2.xml");
        synapseConfiguration = SynapseConfigurationBuilder
                .getConfiguration(configParam.getValue().toString().trim());
    } else {
        log.warn("System property '" + Constants.SYNAPSE_XML
                + "' is not specified or 'SynapseConfiguration' Parameter "
                + "is not available via axis2.xml.  Using default configuration..");
        synapseConfiguration = SynapseConfigurationBuilder.getDefaultConfiguration();
    }

    // Set the Axis2 ConfigurationContext to the SynapseConfiguration
    synapseConfiguration.setAxisConfiguration(cfgCtx.getAxisConfiguration());

    // set the Synapse configuration and environment into the Axis2 configuration
    Parameter synapseCtxParam = new Parameter(Constants.SYNAPSE_CONFIG, null);
    synapseCtxParam.setValue(synapseConfiguration);

    Parameter synapseEnvParam = new Parameter(Constants.SYNAPSE_ENV, null);

    Parameter synEnvImpl = axisConfiguration.getParameter(Constants.SYNAPSE_ENV_IMPL);
    if (synEnvImpl != null && synEnvImpl.getValue() != null) {
        String clazz = (String) synEnvImpl.getValue();
        try {
            Constructor constr = Class.forName(clazz)
                    .getDeclaredConstructor(new Class[] { ConfigurationContext.class });
            synapseEnvParam.setValue(constr.newInstance(new Object[] { cfgCtx }));
        } catch (ClassNotFoundException e) {
            handleException("Cannot find Synapse environment implementation : " + clazz, e);
        } catch (NoSuchMethodException e) {
            handleException("Cannot find Synapse environment constructor : " + clazz, e);
        } catch (IllegalAccessException e) {
            handleException("Error instantiating Synapse environment with : " + clazz, e);
        } catch (InvocationTargetException e) {
            handleException("Error invoking constructor of Synapse environment : " + clazz, e);
        } catch (InstantiationException e) {
            handleException("Error instantiating Synapse environment with : " + clazz, e);
        }
    } else {
        synapseEnvParam.setValue(new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration));
    }

    try {
        axisConfiguration.addParameter(synapseCtxParam);
        axisConfiguration.addParameter(synapseEnvParam);

    } catch (AxisFault e) {
        String msg = "Could not set parameters '" + Constants.SYNAPSE_CONFIG + "' and/or '"
                + Constants.SYNAPSE_ENV + "'to the Axis2 configuration : " + e.getMessage();
        log.fatal(msg, e);
        throw new SynapseException(msg, e);
    }
    return synapseConfiguration;

}

From source file:fr.bird.bloom.model.DatabaseTreatment.java

/**
 * Do a connection to the database/*from  w  ww  .  ja  v  a2s . c o  m*/
 * @param String choiceStatement : execute, executeQuery or executeUpdate
 * @param String sql : request
 * @return ArrayList<String>
 */
public List<String> executeSQLcommand(String choiceStatement, String sql) {

    //this.getRessourcesMysql();

    List<String> messages = new ArrayList<>();

    try {
        messages.add("\nChargement du driver...");
        Class.forName("com.mysql.jdbc.Driver");
        messages.add("Driver charg !");
    } catch (ClassNotFoundException e) {
        messages.add("Erreur lors du chargement : le driver n'a pas t trouv dans le classpath ! <br/>"
                + e.getMessage());
    }

    try {
        messages.add("Connexion  la base de donnes ...");
        //connexion = DriverManager.getConnection( url, user, password );
        messages.add("Connexion russie !");

        /* Create managing object of request */
        //statement = connexion.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

        messages.add("Objet requte cr !");

        //global method for any SQL script - return a boolean : true if the instruction return ResultSet, false else
        if (Objects.equals(choiceStatement, "execute")) {
            this.setResultat(statement.execute(sql));
            messages.add(sql);
            //messages.add(resultat.toString());
        }
        // SELECT - return ResultSet, with results : TDWG=
        else if (Objects.equals(choiceStatement, "executeQuery")) {
            this.resultSet = statement.executeQuery(sql);
            messages.add(sql);
            ResultSetMetaData resultMeta = this.resultSet.getMetaData();

            setResultatSelect(resultMeta);
            this.resultSet.close();
        }
        /* writing or deleting on DB (for INSERT, UPDATE, DELETE, ...)
         * give lines number edited by INSERT, UPDATE et DELETE
         * or 0 for no return methods like CREATE
         */
        else if (Objects.equals(choiceStatement, "executeUpdate")) {
            i = statement.executeUpdate(sql);
            messages.add(sql);
            //messages.add("nb lignes affectes => " + Integer.toString(i));
        }

        statement.close();

    } catch (SQLException e) {
        messages.add("Connection error : " + e.getMessage());
        do {
            System.out.println("SQLState : " + e.getSQLState());
            System.out.println("Description :  " + e.getMessage());
            System.out.println("Error code :   " + e.getErrorCode());
            System.out.println(sql);
            System.out.println();
            e = e.getNextException();
        } while (e != null);
    }

    return messages;

}

From source file:eu.stratosphere.api.java.io.jdbc.JDBCInputFormat.java

/**
 * Connects to the source database and executes the query.
 *
 * @param ignored//  www  . j  a  va2  s  .com
 * @throws IOException
 */
@Override
public void open(InputSplit ignored) throws IOException {
    try {
        establishConnection();
        statement = dbConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        resultSet = statement.executeQuery(query);
    } catch (SQLException se) {
        close();
        throw new IllegalArgumentException("open() failed." + se.getMessage(), se);
    } catch (ClassNotFoundException cnfe) {
        throw new IllegalArgumentException("JDBC-Class not found. - " + cnfe.getMessage(), cnfe);
    }
}

From source file:com.impetus.kundera.metadata.MetadataManager.java

@Override
// called whenever a class with @Entity annotation is encountered in the
// classpath./*  w ww  . ja  v a 2 s. c o m*/
public final void discovered(String className, String[] annotations) {
    try {
        Class<?> clazz = Class.forName(className);

        // process for Metadata
        EntityMetadata metadata = process(clazz);
        cacheMetadata(clazz, metadata);
        log.info("Added @Entity " + clazz.getName());
    } catch (ClassNotFoundException e) {
        throw new PersistenceException(e.getMessage());
    }
}