Example usage for java.lang ClassNotFoundException toString

List of usage examples for java.lang ClassNotFoundException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:ips1ap101.lib.core.util.ClassX.java

protected Class<?> forName(String className) {
    Bitacora.trace(ClassX.class, "forName", className);
    try {//from   ww  w.  j  a va2  s . co m
        return Class.forName(className);
    } catch (ClassNotFoundException ex) {
        Bitacora.logTrace(ex.toString());
        return null;
    }
}

From source file:org.apache.hadoop.sqoop.orm.TestClassWriter.java

@Before
public void setUp() {
    testServer = new HsqldbTestServer();
    try {//from   w ww .jav a  2s. c om
        testServer.resetServer();
    } catch (SQLException sqlE) {
        LOG.error("Got SQLException: " + sqlE.toString());
        fail("Got SQLException: " + sqlE.toString());
    } catch (ClassNotFoundException cnfe) {
        LOG.error("Could not find class for db driver: " + cnfe.toString());
        fail("Could not find class for db driver: " + cnfe.toString());
    }

    manager = testServer.getManager();
    options = testServer.getImportOptions();
}

From source file:com.cloudera.sqoop.testutil.ReparseMapper.java

public void configure(JobConf job) {
    String userTypeName = job.get(USER_TYPE_NAME_KEY);
    if (null == userTypeName) {
        throw new RuntimeException("Unconfigured parameter: " + USER_TYPE_NAME_KEY);
    }/*www . j  a  v a 2  s. c  o  m*/

    LOG.info("User type name set to " + userTypeName);

    this.userRecord = null;

    try {
        Configuration conf = new Configuration();
        Class userClass = Class.forName(userTypeName, true, Thread.currentThread().getContextClassLoader());
        this.userRecord = (SqoopRecord) ReflectionUtils.newInstance(userClass, conf);
    } catch (ClassNotFoundException cnfe) {
        // handled by the next block.
        LOG.error("ClassNotFound exception: " + cnfe.toString());
    } catch (Exception e) {
        LOG.error("Got an exception reflecting user class: " + e.toString());
    }

    if (null == this.userRecord) {
        LOG.error("Could not instantiate user record of type " + userTypeName);
        throw new RuntimeException("Could not instantiate user record of type " + userTypeName);
    }
}

From source file:com.cloudera.sqoop.testutil.ExplicitSetMapper.java

public void configure(JobConf job) {
    String userTypeName = job.get(USER_TYPE_NAME_KEY);
    if (null == userTypeName) {
        throw new RuntimeException("Unconfigured parameter: " + USER_TYPE_NAME_KEY);
    }/* ww  w  . j ava 2  s.  c om*/

    setCol = job.get(SET_COL_KEY);
    setVal = job.get(SET_VAL_KEY);

    LOG.info("User type name set to " + userTypeName);
    LOG.info("Will try to set col " + setCol + " to " + setVal);

    this.userRecord = null;

    try {
        Configuration conf = new Configuration();
        Class userClass = Class.forName(userTypeName, true, Thread.currentThread().getContextClassLoader());
        this.userRecord = (SqoopRecord) ReflectionUtils.newInstance(userClass, conf);
    } catch (ClassNotFoundException cnfe) {
        // handled by the next block.
        LOG.error("ClassNotFound exception: " + cnfe.toString());
    } catch (Exception e) {
        LOG.error("Got an exception reflecting user class: " + e.toString());
    }

    if (null == this.userRecord) {
        LOG.error("Could not instantiate user record of type " + userTypeName);
        throw new RuntimeException("Could not instantiate user record of type " + userTypeName);
    }
}

From source file:org.openrdf.sail.rdbms.mysql.MySqlStore.java

@Override
public void initialize() throws SailException {
    try {//  ww  w  . j  ava  2  s.c o m
        Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
        throw new RdbmsException(e.toString(), e);
    }
    StringBuilder url = new StringBuilder();
    url.append("jdbc:mysql:");
    if (serverName != null) {
        url.append("//").append(serverName);
        if (portNumber > 0) {
            url.append(":").append(portNumber);
        }
        url.append("/");
    }
    url.append(databaseName);
    url.append("?useUnicode=yes&characterEncoding=UTF-8");
    for (Entry<String, String> e : getProperties().entrySet()) {
        url.append("&");
        url.append(enc(e.getKey()));
        url.append("=");
        url.append(enc(e.getValue()));
    }
    BasicDataSource ds = new BasicDataSource();
    ds.setUrl(url.toString());
    if (user != null) {
        ds.setUsername(user);
    } else {
        ds.setUsername(System.getProperty("user.name"));
    }
    if (password != null) {
        ds.setPassword(password);
    }
    MySqlConnectionFactory factory = new MySqlConnectionFactory();
    factory.setSail(this);
    factory.setDataSource(ds);
    setBasicDataSource(ds);
    setConnectionFactory(factory);
    super.initialize();
}

From source file:org.openrdf.sail.rdbms.postgresql.PgSqlStore.java

@Override
public void initialize() throws SailException {
    try {/*from w  w w  .  j av  a 2s.c  om*/
        Class.forName("org.postgresql.Driver");
    } catch (ClassNotFoundException e) {
        throw new RdbmsException(e.toString(), e);
    }
    StringBuilder url = new StringBuilder();
    url.append("jdbc:postgresql:");
    if (serverName != null) {
        url.append("//").append(serverName);
        if (portNumber > 0) {
            url.append(":").append(portNumber);
        }
        url.append("/");
    }
    url.append(databaseName);
    Iterator<Entry<String, String>> iter;
    iter = getProperties().entrySet().iterator();
    if (iter.hasNext()) {
        url.append("?");
    }
    while (iter.hasNext()) {
        Entry<String, String> e = iter.next();
        url.append(enc(e.getKey()));
        url.append("=");
        url.append(enc(e.getValue()));
        if (iter.hasNext()) {
            url.append("&");
        }
    }
    BasicDataSource ds = new BasicDataSource();
    ds.setUrl(url.toString());
    if (user != null) {
        ds.setUsername(user);
    } else {
        ds.setUsername(System.getProperty("user.name"));
    }
    if (password != null) {
        ds.setPassword(password);
    }
    PgSqlConnectionFactory factory = new PgSqlConnectionFactory();
    factory.setSail(this);
    factory.setDataSource(ds);
    setBasicDataSource(ds);
    setConnectionFactory(factory);
    super.initialize();
}

From source file:uk.co.modularaudio.util.pooling.sql.ConnectionFactory.java

/**
 * <P>// w w w  .ja v a  2 s .c  om
 * Initialise the factory by attempting to get the classes required for the
 * driver.
 * </P>
 *
 * @exception FactoryProductionException
 */
@Override
public void init() throws FactoryProductionException {
    if (classname == null || classname.equals("")) {
        throw new FactoryProductionException("No driver class specified.");
    }

    try {
        Class.forName(classname);
        // Test creating a connection
        final Connection c = getConnection();
        c.close();
    } catch (final ClassNotFoundException cnfe) {
        throw new FactoryProductionException(cnfe.toString());
    } catch (final SQLException sqle) {
        throw new FactoryProductionException(sqle.toString());
    }
}

From source file:com.bskyb.cg.environments.hash.PersistentHash.java

private synchronized void refreshFromStore(String dirname) throws IOException {

    FileInputStream fis;//w  ww  .j a v  a 2 s.c  om
    BufferedInputStream bis;
    Serializable messageEntry;
    ObjectInputStream ois;
    File emptyDir = new File(dirname);
    FilenameFilter onlyDat = new FileExtFilter(STOREFILEEXT);
    File[] files = emptyDir.listFiles(onlyDat);

    hash.clear();

    for (File file : files) {
        fis = new FileInputStream(file);
        bis = new BufferedInputStream(fis);
        ois = new ObjectInputStream(bis);
        try {
            messageEntry = (Serializable) ois.readObject();
        } catch (ClassNotFoundException e) {
            throw new IOException(e.toString());
        } catch (ClassCastException e) {
            throw new IOException(e.toString());
        } catch (StreamCorruptedException e) {
            throw new IOException(e.toString());
        }
        try {
            hash.put(file.getName(), (Message) messageEntry);
        } catch (ClassCastException e) {
            throw new IOException(e.toString());
        }
        fis.close();
    }
}

From source file:org.openiam.spml2.spi.jdbc.AppTableConnectorImpl.java

public ResponseType testConnection(ManagedSys managedSys) {
    ResponseType response = new ResponseType();
    response.setStatus(StatusCodeType.SUCCESS);

    Connection con = null;//from ww  w  . j  av a 2 s . c om

    try {

        con = connectionMgr.connect(managedSys);

    } catch (SQLException se) {
        log.error(se.toString());
        response.setStatus(StatusCodeType.FAILURE);
        response.setError(ErrorCode.SQL_ERROR);
        response.addErrorMessage(se.toString());
        return response;

    } catch (ClassNotFoundException cnfe) {
        log.error(cnfe.toString());
        response.setStatus(StatusCodeType.FAILURE);
        response.setError(ErrorCode.INVALID_CONFIGURATION);
        response.addErrorMessage(cnfe.toString());
        return response;
    } finally {
        /* close the connection to the directory */
        try {
            if (con != null) {
                con.close();
            }
        } catch (Exception n) {
            log.error(n);
        }

    }

    return response;
}

From source file:com.massivedisaster.activitymanager.activity.AbstractFragmentActivity.java

/**
 * Get a new instance of the Fragment.//from   w ww .ja v  a2  s .  c om
 *
 * @param clazz the canonical Fragment name.
 * @return the instance of the Fragment.
 */
private Fragment getFragment(String clazz) {
    try {
        Fragment f = ((Fragment) Class.forName(clazz).newInstance());

        if (getIntent().getExtras() != null) {
            f.setArguments(getIntent().getExtras());
        }

        return f;
    } catch (ClassNotFoundException e) {
        Log.e(ActivityFragmentManager.class.getCanonicalName(), e.toString());
    } catch (IllegalAccessException e) {
        Log.e(ActivityFragmentManager.class.getCanonicalName(), e.toString());
    } catch (InstantiationException e) {
        Log.e(ActivityFragmentManager.class.getCanonicalName(), e.toString());
    }

    return null;
}