Example usage for java.lang ClassNotFoundException printStackTrace

List of usage examples for java.lang ClassNotFoundException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.surenpi.autotest.suite.SuiteRunnerLauncher.java

private static void runFromList(String runnerParser) {
    SuiteParser parser = null;/*  ww  w  . ja va 2s. c o m*/
    try {
        parser = SuiteParserFactory.getInstance(runnerParser);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    }

    if (parser == null) {
        return;
    }

    for (String runner : runnerList) {
        SuiteRunner suiteRunner = new SuiteRunner();
        suiteRunner.setSuiteParser(parser);
        suiteRunner.setApplicationClazz(Configuration.class);
        suiteRunner.runFromFileQuietly(new File(runner));
    }
}

From source file:org.apache.phoenix.hive.util.HiveConnectionUtil.java

/**
 * Returns the {#link Connection} from Configuration
 * @param configuration//from   w  ww .j a  v a2s  .  c  om
 * @return
 * @throws SQLException
 */
public static Connection getConnection(final Configuration configuration) throws SQLException {
    Preconditions.checkNotNull(configuration);
    if (connection == null) {
        final Properties props = new Properties();
        String quorum = configuration
                .get(HiveConfigurationUtil.ZOOKEEPER_QUORUM != null ? HiveConfigurationUtil.ZOOKEEPER_QUORUM
                        : configuration.get(HConstants.ZOOKEEPER_QUORUM));
        String znode = configuration
                .get(HiveConfigurationUtil.ZOOKEEPER_PARENT != null ? HiveConfigurationUtil.ZOOKEEPER_PARENT
                        : configuration.get(HConstants.ZOOKEEPER_ZNODE_PARENT));
        String port = configuration
                .get(HiveConfigurationUtil.ZOOKEEPER_PORT != null ? HiveConfigurationUtil.ZOOKEEPER_PORT
                        : configuration.get(HConstants.ZOOKEEPER_CLIENT_PORT));
        if (!znode.startsWith("/")) {
            znode = "/" + znode;
        }

        try {
            // Not necessary shoud pick it up
            Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");

            LOG.info("Connection info: " + PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR
                    + quorum + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + port
                    + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + znode);

            final Connection conn = DriverManager.getConnection(PhoenixRuntime.JDBC_PROTOCOL
                    + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + quorum + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR
                    + port + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + znode);
            String autocommit = configuration.get(HiveConfigurationUtil.AUTOCOMMIT);
            if (autocommit != null && autocommit.equalsIgnoreCase("true")) {
                conn.setAutoCommit(true);
            } else {
                conn.setAutoCommit(false);
            }
            connection = conn;
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return connection;
}

From source file:com.trial.phonegap.plugin.calendar.CalendarAccessorCreator.java

/**
 * This static method returns a new Instance of the implementation class given by parameter
 * @param className Is a String object with the name of the implementation class
 * @param webView/*from w  w  w.  ja  va  2s .com*/
 * @param ctx
 * @return An instance of CalendarAccessorCreator 
 */
public static CalendarAccessorCreator getInstance(String className, WebView webView, PhonegapActivity ctx) {
    try {
        Class<? extends CalendarAccessorCreator> clazz = Class.forName(className)
                .asSubclass(CalendarAccessorCreator.class);

        // Grab constructor class dynamically.
        Constructor<? extends CalendarAccessorCreator> classConstructor = clazz
                .getConstructor(Class.forName("android.webkit.WebView"), Class.forName("android.app.Activity"));
        return classConstructor.newInstance(webView, ctx);

    } catch (ClassNotFoundException e) {
        Log.e(LOG_TAG, "Instantiation Error, class not found:" + className);
        e.printStackTrace();
    } catch (InstantiationException e) {
        Log.e(LOG_TAG, "Instantiation Error:" + className);
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        Log.e(LOG_TAG, "Instantiation Error, illegal access:" + className);
        e.printStackTrace();
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
    return null;
}

From source file:com.skilrock.lms.common.db.DBConnect.java

public static Connection getPropFileCon() {

    Connection connection = null;
    try {/*from w  w  w .j av a2 s . c om*/
        Class.forName("com.mysql.jdbc.Driver");
        connection = DriverManager.getConnection(url, userName, password);

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (SQLException se) {
        se.printStackTrace();
    }

    return connection;
}

From source file:tools.datasync.core.sampleapp.CamelSeedIntegrationTests.java

private static Connection createConnection(String dbName, boolean create) {

    setupDerbyProps();/*from   w  w  w.j  a  v  a 2  s. c o m*/

    try {
        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw (new RuntimeException("Could not load derby driver"));
    }

    Connection conn = null;
    try {
        conn = DriverManager.getConnection("jdbc:derby:" + dbName + ";create=true");
    } catch (SQLException e) {
        Utils.closeQuietly(conn);
        throw (new RuntimeException(e));
    }
    return (conn);

}

From source file:com.vsct.dt.hesperides.templating.models.annotation.HesperidesAnnotationConstructor.java

/**
 * Create annotation object.//from w  w w .j  a  va  2 s. co  m
 *
 * @param annotation annotation like "@default" or "default"
 * @param value value of annotation
 *
 * @return anootation object or null if annotation not found.
 */
public static HesperidesAnnotation createAnnotationObject(final String annotation, final String value) {
    String classAnnotation;
    HesperidesAnnotation obj = null;

    if (annotation.startsWith("@")) {
        classAnnotation = StringUtils.capitalize(annotation.substring(1).toLowerCase());
    } else {
        classAnnotation = StringUtils.capitalize(annotation.toLowerCase());
    }

    try {
        Class<HesperidesAnnotation> clazz = (Class<HesperidesAnnotation>) Class.forName(String.format(
                "com.vsct.dt.hesperides.templating.models.annotation.Hesperides%sAnnotation", classAnnotation));

        Constructor<HesperidesAnnotation> constructor = clazz.getConstructor(String.class, String.class);

        obj = constructor.newInstance(classAnnotation.toLowerCase(), value);
    } catch (ClassNotFoundException e) {
        // Not good.
    } catch (NoSuchMethodException e) {
        // Not good.
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        // Not good.
    } catch (IllegalAccessException e) {
        // Not good.
    }

    return obj;
}

From source file:com.he5ed.lib.cloudprovider.utils.AuthHelper.java

/**
 * Get parameters to be passed to Volley request to get access token
 *
 * @param cloudApi type of cloud account
 * @param authCode code from authorization process
 * @return Map//  ww w  . j  ava 2 s  .c om
 */
public static RequestBody getAccessTokenBody(String cloudApi, String authCode) {
    // use reflection for flexibility
    try {
        Class<?> clazz = Class.forName(cloudApi);
        Method getAccessTokenBody = clazz.getMethod("getAccessTokenBody", String.class);
        return (RequestBody) getAccessTokenBody.invoke(null, authCode);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:com.he5ed.lib.cloudprovider.utils.AuthHelper.java

/**
 * Create OkHttp request to get user information
 *
 * @param cloudApi type of cloud account
 * @param accessToken access token for authorization
 * @return Request//from  w w  w.j  av a 2 s. c  o  m
 */
public static Request getUserInfoRequest(String cloudApi, String accessToken) {
    // use reflection for flexibility
    try {
        Class<?> clazz = Class.forName(cloudApi);
        Method getUserInfoRequest = clazz.getMethod("getUserInfoRequest", String.class);
        return (Request) getUserInfoRequest.invoke(null, accessToken);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:com.he5ed.lib.cloudprovider.utils.AuthHelper.java

/**
 * Extract user information from the JSONObject
 *
 * @param cloudApi type of cloud account
 * @param jsonObject JSONObject that contain user information
 * @return User/*from   w  w w. j  av a 2s . co m*/
 * @throws JSONException
 */
public static User extractUser(String cloudApi, JSONObject jsonObject) throws JSONException {
    // use reflection for flexibility
    try {
        Class<?> clazz = Class.forName(cloudApi);
        Method extractUser = clazz.getMethod("extractUser", JSONObject.class);
        return (User) extractUser.invoke(null, jsonObject);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        // catch exception throw by class method
        if (e.getCause() instanceof JSONException) {
            throw new JSONException(e.getMessage());
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:com.he5ed.lib.cloudprovider.utils.AuthHelper.java

/**
 * Extract access token from the JSONObject
 *
 * @param cloudApi type of cloud account
 * @param jsonObject JSONObject that contain access token
 * @return Map//from  www  . j  ava 2s.  com
 * @throws JSONException
 */
public static Map<String, String> extractAccessToken(String cloudApi, JSONObject jsonObject)
        throws JSONException {
    // use reflection for flexibility
    try {
        Class<?> clazz = Class.forName(cloudApi);
        Method extractAccessToken = clazz.getMethod("extractAccessToken", JSONObject.class);
        return (Map) extractAccessToken.invoke(null, jsonObject);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        // catch exception throw by class method
        if (e.getCause() instanceof JSONException) {
            throw new JSONException(e.getMessage());
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    return null;
}