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:org.sakaiproject.orm.ibatis.support.BlobSerializableTypeHandler.java

protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler)
        throws SQLException, IOException {

    InputStream is = lobHandler.getBlobAsBinaryStream(rs, index);
    if (is != null) {
        ObjectInputStream ois = new ObjectInputStream(is);
        try {/*w  w  w  .ja  v  a2 s . com*/
            return ois.readObject();
        } catch (ClassNotFoundException ex) {
            throw new SQLException("Could not deserialize BLOB contents: " + ex.getMessage());
        } finally {
            ois.close();
        }
    } else {
        return null;
    }
}

From source file:com.berkgokden.mongodb.MongoMapStore.java

public Map loadAll(Collection keys) {
    Map map = new HashMap();
    BasicDBList dbo = new BasicDBList();
    for (Object key : keys) {
        dbo.add(new BasicDBObject("_id", key));
    }/*from w w w  .j  a  v a2s .co  m*/
    BasicDBObject dbb = new BasicDBObject("$or", dbo);
    DBCursor cursor = coll.find(dbb);
    while (cursor.hasNext()) {
        try {
            DBObject obj = cursor.next();
            Class clazz = Class.forName(obj.get("_class").toString());
            map.put(obj.get("_id"), converter.toObject(clazz, obj));
        } catch (ClassNotFoundException e) {
            logger.log(Level.WARNING, e.getMessage(), e);
        }
    }
    return map;
}

From source file:com.otiliouine.configurablefactory.ConfigurableFactory.java

private void loadConfiguration(InputStream inputStream) {
    try {/*from w w  w  .ja  v a  2  s . com*/
        Document document = loadDocument(inputStream);
        document.getDocumentElement().normalize();
        NodeList nList = document.getElementsByTagName("factory");
        for (int index = 0; index < nList.getLength(); index++) {
            Element node = (Element) nList.item(index);
            String superClass = node.getAttribute("interface");
            String implementation = node.getAttribute("implementation");
            Class<?> superClazz = Class.forName(superClass);
            Class<?> subClazz = Class.forName(implementation);
            mapping.put(superClazz, subClazz);
        }
    } catch (ClassNotFoundException e) {
        throw new InvalidMappingValuesException(e.getMessage(), e);
    }
}

From source file:com.cws.esolutions.core.utils.NetworkUtils.java

/**
 * Creates an telnet connection to a target host and port number. Silently
 * succeeds if no issues are encountered, if so, exceptions are logged and
 * re-thrown back to the requestor.//from w w w .  j  a v a  2s.co  m
 *
 * If an exception is thrown during the <code>socket.close()</code> operation,
 * it is logged but NOT re-thrown. It's not re-thrown because it does not indicate
 * a connection failure (indeed, it means the connection succeeded) but it is
 * logged because continued failures to close the socket could result in target
 * system instability.
 * 
 * @param hostName - The target host to make the connection to
 * @param portNumber - The port number to attempt the connection on
 * @param timeout - How long to wait for a connection to establish or a response from the target
 * @param object - The serializable object to send to the target
 * @return <code>Object</code> as output from the request
 * @throws UtilityException {@link com.cws.esolutions.core.utils.exception.UtilityException} if an error occurs processing
 */
public static final synchronized Object executeTcpRequest(final String hostName, final int portNumber,
        final int timeout, final Object object) throws UtilityException {
    final String methodName = NetworkUtils.CNAME
            + "#executeTcpRequest(final String hostName, final int portNumber, final int timeout, final Object object) throws UtilityException";

    if (DEBUG) {
        DEBUGGER.debug(methodName);
        DEBUGGER.debug(hostName);
        DEBUGGER.debug("portNumber: {}", portNumber);
        DEBUGGER.debug("timeout: {}", timeout);
        DEBUGGER.debug("object: {}", object);
    }

    Socket socket = null;
    Object resObject = null;

    try {
        synchronized (new Object()) {
            if (StringUtils.isEmpty(InetAddress.getByName(hostName).toString())) {
                throw new UnknownHostException("No host was found in DNS for the given name: " + hostName);
            }

            InetSocketAddress socketAddress = new InetSocketAddress(hostName, portNumber);

            socket = new Socket();
            socket.setSoTimeout((int) TimeUnit.SECONDS.toMillis(timeout));
            socket.setSoLinger(false, 0);
            socket.setKeepAlive(false);
            socket.connect(socketAddress, (int) TimeUnit.SECONDS.toMillis(timeout));

            if (!(socket.isConnected())) {
                throw new ConnectException("Failed to connect to host " + hostName + " on port " + portNumber);
            }

            ObjectOutputStream objectOut = new ObjectOutputStream(socket.getOutputStream());

            if (DEBUG) {
                DEBUGGER.debug("ObjectOutputStream: {}", objectOut);
            }

            objectOut.writeObject(object);

            resObject = new ObjectInputStream(socket.getInputStream()).readObject();

            if (DEBUG) {
                DEBUGGER.debug("resObject: {}", resObject);
            }

            PrintWriter pWriter = new PrintWriter(socket.getOutputStream(), true);

            pWriter.println(NetworkUtils.TERMINATE_TELNET + NetworkUtils.CRLF);

            pWriter.flush();
            pWriter.close();
        }
    } catch (ConnectException cx) {
        throw new UtilityException(cx.getMessage(), cx);
    } catch (UnknownHostException ux) {
        throw new UtilityException(ux.getMessage(), ux);
    } catch (SocketException sx) {
        throw new UtilityException(sx.getMessage(), sx);
    } catch (IOException iox) {
        throw new UtilityException(iox.getMessage(), iox);
    } catch (ClassNotFoundException cnfx) {
        throw new UtilityException(cnfx.getMessage(), cnfx);
    } finally {
        try {
            if ((socket != null) && (!(socket.isClosed()))) {
                socket.close();
            }
        } catch (IOException iox) {
            // log it - this could cause problems later on
            ERROR_RECORDER.error(iox.getMessage(), iox);
        }
    }

    return resObject;
}

From source file:com.tdclighthouse.prototype.maven.PrototypeSupperClassHandler.java

private Class<?> getClass(HippoBeanClass hippoBeanClass) {
    try {/*  w  ww .  j  ava  2s  .c  om*/
        return Class.forName(hippoBeanClass.getFullyQualifiedName(), true, getClassLoader());
    } catch (ClassNotFoundException e) {
        throw new HandlerException(e.getMessage(), e);
    }
}

From source file:ca.ualberta.physics.cssdp.util.JSONClassDeserializer.java

@Override
public Class<?> deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    try {/*from   ww w.  java 2 s. c  o  m*/
        return Class.forName(jp.getText());
    } catch (ClassNotFoundException e) {
        logger.error("Could not deserialize json representation of URI " + jp.getText()
                + " into URI object because " + e.getMessage(), e);
    }
    return null;
}

From source file:org.apache.hadoop.hbase.procedure.ProcedureManagerHost.java

/**
 * Load system procedures. Read the class names from configuration.
 * Called by constructor./*  w  w w.ja  va2s  . c  om*/
 */
protected void loadUserProcedures(Configuration conf, String confKey) {
    Class<?> implClass = null;

    // load default procedures from configure file
    String[] defaultProcClasses = conf.getStrings(confKey);
    if (defaultProcClasses == null || defaultProcClasses.length == 0)
        return;

    List<E> configured = new ArrayList<E>();
    for (String className : defaultProcClasses) {
        className = className.trim();
        ClassLoader cl = this.getClass().getClassLoader();
        Thread.currentThread().setContextClassLoader(cl);
        try {
            implClass = cl.loadClass(className);
            configured.add(loadInstance(implClass));
            LOG.info("User procedure " + className + " was loaded successfully.");
        } catch (ClassNotFoundException e) {
            LOG.warn("Class " + className + " cannot be found. " + e.getMessage());
        } catch (IOException e) {
            LOG.warn("Load procedure " + className + " failed. " + e.getMessage());
        }
    }

    // add entire set to the collection
    procedures.addAll(configured);
}

From source file:com.emr.utilities.DatabaseManager.java

/**
 * Constructor/*from  w ww  .  j  av  a  2s  . c  om*/
 * @param servername {@link String} Server name
 * @param port {@link String} Server Mysql Port
 * @param dbName {@link String} Database name
 * @param username {@link String} Mysql Username
 * @param password {@link String} Password
 */
public DatabaseManager(String servername, String port, String dbName, String username, String password) {
    this.servername = servername;
    this.port = port;
    this.url = "jdbc:mysql://" + servername + ":" + port + "/";
    this.dbName = dbName;
    this.userName = username;
    this.password = password;
    this.driver = "com.mysql.jdbc.Driver";
    try {
        Class.forName(driver).newInstance();
        conn = DriverManager.getConnection(url + dbName, userName, password);
    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
        JOptionPane.showMessageDialog(null, "SQLException: " + ex.getMessage(), "Exception!",
                JOptionPane.ERROR_MESSAGE);
    } catch (ClassNotFoundException cs) {
        System.out.println("Class not found: " + cs.getMessage());
        JOptionPane.showMessageDialog(null, "Class not found: " + cs.getMessage(), "Exception!",
                JOptionPane.ERROR_MESSAGE);
    } catch (InstantiationException | IllegalAccessException i) {
        System.out.println("Instantiation/Illegal State Error: " + i.getMessage());
        JOptionPane.showMessageDialog(null, "Instantiation/Illegal State Error: " + i.getMessage(),
                "Exception!", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:org.thingsplode.synapse.serializers.jackson.adapters.ParameterWrapperDeserializer.java

@Override
public ParameterWrapper deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    JsonNode node = jp.readValueAsTree();
    if (node != null && node.size() > 0 && node.isContainerNode()) {
        ParameterWrapper pw = ParameterWrapper.create();
        ArrayNode paramsNode = (ArrayNode) node.get("params");
        Iterator<JsonNode> elemIterator = paramsNode.elements();
        while (elemIterator.hasNext()) {
            JsonNode currentNode = elemIterator.next();
            if (currentNode.getNodeType() == JsonNodeType.OBJECT) {
                try {
                    String paramid = ((ObjectNode) currentNode).get("paramid").asText();
                    String typeName = ((ObjectNode) currentNode).get("type").asText();
                    Class paramType = null;
                    if (null != typeName)
                        switch (typeName) {
                        case "long":
                            paramType = Long.TYPE;
                            break;
                        case "byte":
                            paramType = Byte.TYPE;
                            break;
                        case "short":
                            paramType = Short.TYPE;
                            break;
                        case "int":
                            paramType = Integer.TYPE;
                            break;
                        case "float":
                            paramType = Float.TYPE;
                            break;
                        case "double":
                            paramType = Double.TYPE;
                            break;
                        case "boolean":
                            paramType = Boolean.TYPE;
                            break;
                        case "char":
                            paramType = Character.TYPE;
                            break;
                        default:
                            paramType = Class.forName(typeName);
                            break;
                        }/*  w  w  w  .j av a  2  s .com*/
                    Object parameterObject = jp.getCodec().treeToValue(currentNode.get("value"), paramType);
                    pw.add(paramid, paramType, parameterObject);
                } catch (ClassNotFoundException ex) {
                    throw new JsonParseException(jp, ex.getMessage());
                }
            }
        }
        return pw;
    } else {
        return null;
    }
}

From source file:com.liferay.portal.servlet.SharedServletWrapper.java

public void init(ServletConfig sc) throws ServletException {
    super.init(sc);

    ServletContext ctx = getServletContext();

    _servletContextName = StringUtil.replace(ctx.getServletContextName(), StringPool.SPACE,
            StringPool.UNDERLINE);/*  w  ww .j ava2 s.c o  m*/

    _servletClass = sc.getInitParameter("servlet-class");

    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

    try {
        _servletInstance = (Servlet) contextClassLoader.loadClass(_servletClass).newInstance();
    } catch (ClassNotFoundException cnfe) {
        throw new ServletException(cnfe.getMessage());
    } catch (IllegalAccessException iae) {
        throw new ServletException(iae.getMessage());
    } catch (InstantiationException ie) {
        throw new ServletException(ie.getMessage());
    }

    if (_servletInstance instanceof HttpServlet) {
        _httpServletInstance = (HttpServlet) _servletInstance;

        _httpServletInstance.init(sc);
    } else {
        _servletInstance.init(sc);
    }
}