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:alpha.portal.webapp.taglib.ConstantsTag.java

/**
 * Main method that does processing and exposes Constants in specified
 * scope.// w  w  w.  j  a va 2  s .com
 * 
 * @return int
 * @throws JspException
 *             if processing fails
 */
@Override
public int doStartTag() throws JspException {
    // Using reflection, get the available field names in the class
    Class c = null;
    int toScope = PageContext.PAGE_SCOPE;

    if (this.scope != null) {
        toScope = this.getScope(this.scope);
    }

    try {
        c = Class.forName(this.clazz);
    } catch (final ClassNotFoundException cnf) {
        this.log.error("ClassNotFound - maybe a typo?");
        throw new JspException(cnf.getMessage());
    }

    try {
        // if var is null, expose all variables
        if (this.var == null) {
            final Field[] fields = c.getDeclaredFields();

            AccessibleObject.setAccessible(fields, true);

            for (final Field field : fields) {
                this.pageContext.setAttribute(field.getName(), field.get(this), toScope);
            }
        } else {
            try {
                final Object value = c.getField(this.var).get(this);
                this.pageContext.setAttribute(c.getField(this.var).getName(), value, toScope);
            } catch (final NoSuchFieldException nsf) {
                this.log.error(nsf.getMessage());
                throw new JspException(nsf);
            }
        }
    } catch (final IllegalAccessException iae) {
        this.log.error("Illegal Access Exception - maybe a classloader issue?");
        throw new JspException(iae);
    }

    // Continue processing this page
    return (Tag.SKIP_BODY);
}

From source file:com.npower.unicom.sync.AbstractExportDaemonPlugIn.java

/**
 * /*from ww w .  ja  v a  2 s.  com*/
 * @param date
 */
private Date loadLastSyncTimeStamp() {
    File requestDir = this.getRequestDir();
    File file = new File(requestDir, AbstractExportDaemonPlugIn.FILENAME_LAST_SYNC_TIME_STAMP);
    try {
        if (file.exists()) {
            ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
            Date time = (Date) in.readObject();
            in.close();
            return time;
        }
    } catch (ClassNotFoundException e) {
        log.error("failure to update last sync time stamp: " + e.getMessage(), e);
    } catch (IOException e) {
        log.error("failure to update last sync time stamp: " + e.getMessage(), e);
    }
    return null;
}

From source file:ch.tatool.app.service.impl.ModuleServiceImpl.java

/** Creates an object given the property containing the class name, as well as of
 * what type the object should be of.//w  w  w  . j ava  2  s  . c om
 * @param module
 * @param propertyName
 * @param assignableTo
 */
private Object instantiateObject(Module module, String propertyName, Class<?> assignableTo) {
    // find the scheduler class
    Class<?> c = null;
    String className = module.getModuleProperties().get(propertyName);
    if (className != null && className.length() > 0) {
        try {
            c = Class.forName(className);
        } catch (ClassNotFoundException e) {
            logger.warn("Class not found: " + e.getMessage(), e);
        }
    }
    if (c == null) {
        return null;
    }

    // Make sure the class is assignable as requested
    if (assignableTo != null && !assignableTo.isAssignableFrom(c)) {
        logger.warn("Class " + c.getName() + " is not assigable to class " + assignableTo.getName());
        return null;
    }

    // try to instantiate an object
    Object o = null;
    try {
        o = c.newInstance();
    } catch (InstantiationException e) {
        logger.error("Unable to create session scheduler", e);
    } catch (IllegalAccessException e) {
        logger.error("Unable to create session scheduler", e);
    }
    return o;
}

From source file:hermes.store.schema.DefaultJDBCAdapter.java

public DefaultJDBCAdapter() throws IOException {
    try {/* w  w w .  j ava2 s. c o  m*/
        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
    } catch (ClassNotFoundException e) {
        log.error("default Derby JDBC driver not loaded: " + e.getMessage(), e);
    }
}

From source file:com.icesoft.faces.webapp.parser.Parser.java

public Parser(InputStream fis) throws IOException {
    // Create digester and add rules;
    digester = new JsfJspDigester();
    digester.setNamespaceAware(true);/* www  .ja va 2  s  . c om*/
    digester.setValidating(false);
    digester.setUseContextClassLoader(false);
    digester.setClassLoader(this.getClass().getClassLoader());

    try {
        TagToComponentMap map = TagToComponentMap.loadFrom(fis);
        digester.addRuleSet(new ComponentRuleSet(map, ""));
    } catch (ClassNotFoundException e) {
        throw new IOException(e.getMessage());
    } finally {
        fis.close();
    }
}

From source file:com.xtructure.xutil.AbstractRunTests.java

/**
 * Attempts to add the named class to the internally maintained list of test
 * classes.//ww  w .j a  va  2s .  c  o m
 * 
 * @param className
 *            the name of the class to add
 */
private final void addClass(final String className) {
    try {
        _classes.add(Class.forName(className));
    } catch (ClassNotFoundException classNotFoundEx) {
        throw new RuntimeException("couldn't get class '" + className + "': " + classNotFoundEx.getMessage(),
                classNotFoundEx);
    }
}

From source file:javazoom.jlgui.player.amp.tag.TagInfoFactory.java

/**
 * Load and check class implementation from classname.
 *
 * @param classname/*from ww w  .  java 2s .  co  m*/
 * @return TagInfo implementation for given class name
 */
public Class getTagInfoImpl(String classname) {
    Class aClass = null;
    boolean interfaceFound = false;
    if (classname != null) {
        try {
            aClass = Class.forName(classname);
            Class superClass = aClass;
            // Looking for TagInfo interface implementation.
            while (superClass != null) {
                Class[] interfaces = superClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if ((interfaces[i].getName()).equals("javazoom.jlgui.player.amp.tag.TagInfo")) {
                        interfaceFound = true;
                        break;
                    }
                }
                if (interfaceFound)
                    break;
                superClass = superClass.getSuperclass();
            }
            if (interfaceFound)
                log.info(classname + " loaded");
            else
                log.info(classname + " not loaded");
        } catch (ClassNotFoundException e) {
            log.error("Error : " + classname + " : " + e.getMessage());
        }
    }
    return aClass;
}

From source file:com.fluidops.iwb.provider.SilkProvider.java

@Override
public MappingType gatherMapping(final List<Statement> res) throws Exception {
    String rand = Rand.getIncrementalFluidUUID();

    // temporary files
    if (StringUtil.isNullOrEmpty(tmpFolderPath))
        tmpFolderPath = IWBFileUtil.getSilkFolder().getPath();
    File tmpOutputFile = new File(tmpFolderPath + "/silk-result-" + rand + ".nt");
    File tmpConfigFile = new File(tmpFolderPath + "/silk-config-" + rand + ".xml");

    try {/*from   w  ww.j  a  v  a2s .  c  o  m*/
        String silkConfig = configToSilkConfig(config, tmpOutputFile.getAbsolutePath());
        FileUtil.writeContentToFile(silkConfig, tmpConfigFile.getAbsolutePath());

        // we make the following calls by reflection, to avoid compile-time dependencies towards
        // SILK; note that, when using the SILK provider locally, you need to install Scala and
        // compile the scalasrc folder (i.e., give the fiwb project the scala nature and
        // compile the fiwb/scalasrc folder with scalac)
        try {
            logger.info("Registering IWB plugin to SILK...");
            Method registerPluginMethod = Class.forName("com.fluidops.iwb.silk.IwbPlugins")
                    .getMethod("register");
            registerPluginMethod.invoke(null);

            logger.info("Executing SILK...");
            Method executeFile = Class.forName("com.fluidops.iwb.silk.IwbSilk").getMethod("executeFile",
                    java.io.File.class);
            executeFile.invoke(null, tmpConfigFile);
        } catch (ClassNotFoundException e) {
            String message = e.getMessage() + "\n";
            message += "To run the SILK provider locally, you need to compile the sources using Scala. ";
            message += "Please make sure that you hava scala installed, add the scala nature to fiwb,";
            message += "add iwb/scalasrc as a source folder, and compile the SILK scala bindings. ";
            message += "Alternatively, you may extract the classes in scalasrc as a .jar from the build.";

            throw new IllegalStateException(message);
        } catch (Exception e) {
            logger.warn(e.getMessage(), e);
            throw e;
        }

        logger.info("Parsing SILK result file to statement list");
        parseFileToStmtList(tmpOutputFile, res);

        logger.info("All done, returning to provider mechanism");
    } finally {
        // cleanup tmp directory
        try {
            tmpOutputFile.delete();
        } catch (Exception e) {
            logger.warn(e.getMessage());
        }

        try {
            tmpConfigFile.delete();
        } catch (Exception e) {
            logger.warn(e.getMessage());
        }
    }

    return config.mappingType;
}

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

/**
 * SQL?/*  w w  w .  j  a va2s .com*/
 * 
 * @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();
                m_value = rSet.getString(1);

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

                NumberFormat numberFormat = NumberFormat.getNumberInstance();
                m_messageOrg = MessageConstant.RECORD_VALUE.getMessage() + " : " + 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:org.codehaus.groovy.grails.plugins.CorePluginFinder.java

private Class<?> attemptCorePluginClassLoad(String pluginClassName) {
    try {/*ww  w  .  j av a 2  s.c o  m*/
        final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        return classLoader.loadClass(pluginClassName);
    } catch (ClassNotFoundException e) {
        LOG.warn("[GrailsPluginManager] Core plugin [" + pluginClassName
                + "] not found, resuming load without..");
        if (LOG.isDebugEnabled()) {
            LOG.debug(e.getMessage(), e);
        }
    }
    return null;
}