List of usage examples for java.lang ClassNotFoundException getMessage
public String getMessage()
From source file:com.aurel.track.fieldType.types.FieldType.java
/** * Get the FieldType by class name//from w w w .j av a 2 s .c om * @param fieldTypeClassName * @return */ public static FieldType fieldTypeFactory(String fieldTypeClassName) { Class fieldTypeClass = null; if (fieldTypeClassName == null) { LOGGER.warn("No fieldType specified "); return null; } try { fieldTypeClass = Class.forName(fieldTypeClassName); } catch (ClassNotFoundException e) { LOGGER.warn("The fieldType class " + fieldTypeClassName + " not found found in the classpath " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (fieldTypeClass != null) try { return (FieldType) fieldTypeClass.newInstance(); } catch (Exception e) { LOGGER.warn("Instantiating the fieldType class " + fieldTypeClassName + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } return null; }
From source file:com.sketchy.server.ServletAction.java
public static synchronized ServletAction getInstance(String servletActionClassName) throws Exception { try {/*from ww w.j a v a 2s. c o m*/ ServletAction servletAction = instanceMap.get(servletActionClassName); if (servletAction == null) { servletAction = (ServletAction) Class.forName(servletActionClassName).newInstance(); instanceMap.put(servletActionClassName, servletAction); } return servletAction; } catch (ClassNotFoundException e) { throw e; } catch (Exception e) { throw new Exception("Error creating ServletAction Instance for class '" + servletActionClassName + "'! " + e.getMessage()); } }
From source file:com.sun.portal.os.portlets.PortletChartUtilities.java
private static Connection getDatabaseConnection(ResourceRequest request) throws SQLException, NoPreferredDbSetException { PortletPreferences prefs = request.getPreferences(); if (prefs == null) throw new NoPreferredDbSetException("No Preferences Set.. Don't know what DB to connect to"); String driverUrl = prefs.getValue(Constants.PREF_JDBC_DRIVER_URL, JDBC_URL); String driverClass = prefs.getValue(Constants.PREF_JDBC_DRIVER_CLASS, MYSQL_JDBC_DRIVER); debugMessage("Driver Class: " + driverClass); debugMessage("Driver URL : " + driverUrl); try {//from w w w . j a v a 2 s . c o m Class.forName(driverClass); } catch (ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } return DriverManager.getConnection(driverUrl); }
From source file:Operacional.Janela2.java
static Class class$(String s) { try {//w ww. j a va2s. co m return Class.forName(s); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } ClassNotFoundException classnotfoundexception = null; throw new NoClassDefFoundError(classnotfoundexception.getMessage()); }
From source file:org.apache.tajo.util.ClassUtil.java
private static void findClasses(Set<Class> matchedClassSet, File root, File file, boolean includeJars, @Nullable Class type, String packageFilter, @Nullable Predicate predicate) { if (file.isDirectory()) { for (File child : file.listFiles()) { findClasses(matchedClassSet, root, child, includeJars, type, packageFilter, predicate); }// ww w. j av a 2s.c om } else { if (file.getName().toLowerCase().endsWith(".jar") && includeJars) { JarFile jar = null; try { jar = new JarFile(file); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); return; } Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); String name = entry.getName(); int extIndex = name.lastIndexOf(".class"); if (extIndex > 0) { String qualifiedClassName = name.substring(0, extIndex).replace("/", "."); if (qualifiedClassName.indexOf(packageFilter) >= 0 && !isTestClass(qualifiedClassName)) { try { Class clazz = Class.forName(qualifiedClassName); if (isMatched(clazz, type, predicate)) { matchedClassSet.add(clazz); } } catch (ClassNotFoundException e) { LOG.error(e.getMessage(), e); } } } } try { jar.close(); } catch (IOException e) { LOG.warn("Closing " + file.getName() + " was failed."); } } else if (file.getName().toLowerCase().endsWith(".class")) { String qualifiedClassName = createClassName(root, file); if (qualifiedClassName.indexOf(packageFilter) >= 0 && !isTestClass(qualifiedClassName)) { try { Class clazz = Class.forName(qualifiedClassName); if (isMatched(clazz, type, predicate)) { matchedClassSet.add(clazz); } } catch (ClassNotFoundException e) { LOG.error(e.getMessage(), e); } } } } }
From source file:de.betterform.xml.xforms.CustomElementFactory.java
/** * Loads the configuration for custom elements. * /*from ww w . j a va2 s .co m*/ * @return A Map where the keys are in the format namespace-uri:element-name * and the value is the reference to the class that implements the * custom element, or an empty map if the configuration could not be * loaded for some reason. */ private static Map getCustomElementsConfig() { try { Map elementClassNames = Config.getInstance().getCustomElements(); Map elementClassRefs = new HashMap(elementClassNames.size()); Iterator itr = elementClassNames.entrySet().iterator(); //converts class names into the class references while (itr.hasNext()) { Map.Entry entry = (Entry) itr.next(); String key = (String) entry.getKey(); String className = (String) entry.getValue(); Class classRef = Class.forName(className, true, CustomElementFactory.class.getClassLoader()); elementClassRefs.put(key, classRef); } //return the configuration return elementClassRefs; } catch (XFormsConfigException xfce) { LOGGER.error("could not load custom-elements config: " + xfce.getMessage()); } catch (ClassNotFoundException cnfe) { LOGGER.error("class configured for custom-element not found: " + cnfe.getMessage()); } //returns an empty map (no custom elements) return Collections.EMPTY_MAP; }
From source file:com.bluexml.side.build.tools.graph.jung.algorithms.GraphFilter.java
public static boolean testClassName(Object o, String name) { Class<?> forName;/*from www.j a v a2s. c o m*/ try { forName = Class.forName("com.bluexml.side.build.tools.componants." + name); return forName.isInstance(o); } catch (ClassNotFoundException e) { logger.error(e.getMessage(), e); } return false; }
From source file:edumsg.core.PostgresConnection.java
public static void initSource() { try {/*from w w w .j a va2s.c om*/ try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException ex) { LOGGER.log(Level.SEVERE, "Error loading Postgres driver: " + ex.getMessage(), ex); } try { readConfFile(); } catch (Exception e) { e.printStackTrace(); } Properties props = new Properties(); // System.out.println(DB_USERNAME); props.setProperty("user", DB_USERNAME); props.setProperty("password", DB_PASSWORD); props.setProperty("initialSize", DB_INIT_CONNECTIONS); props.setProperty("maxActive", DB_MAX_CONNECTIONS); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(DB_URL, props); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null); poolableConnectionFactory.setPoolStatements(true); GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setMaxIdle(Integer.parseInt(DB_INIT_CONNECTIONS)); poolConfig.setMaxTotal(Integer.parseInt(DB_MAX_CONNECTIONS)); ObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory, poolConfig); poolableConnectionFactory.setPool(connectionPool); Class.forName("org.apache.commons.dbcp2.PoolingDriver"); dbDriver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:"); dbDriver.registerPool(DB_NAME, connectionPool); dataSource = new PoolingDataSource<>(connectionPool); } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Got error initializing data source: " + ex.getMessage(), ex); } }
From source file:org.alfresco.web.bean.wcm.AVMWorkflowUtil.java
/** * Deserialize the default workflow params from a content stream * /*from ww w.ja v a2 s .c o m*/ * @param workflowRef The noderef to write the property too * * @return Serializable workflow params */ public static Serializable deserializeWorkflowParams(NodeRef workflowRef) { try { // restore the serialized Map from a binary content stream - like database blob! Serializable params = null; ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()) .getContentService(); ContentReader reader = cs.getReader(workflowRef, WCMAppModel.PROP_WORKFLOW_DEFAULT_PROPERTIES); if (reader != null) { ObjectInputStream ois = new ObjectInputStream(reader.getContentInputStream()); params = (Serializable) ois.readObject(); ois.close(); } return params; } catch (IOException ioErr) { throw new AlfrescoRuntimeException( "Unable to deserialize workflow default parameters: " + ioErr.getMessage()); } catch (ClassNotFoundException classErr) { throw new AlfrescoRuntimeException( "Unable to deserialize workflow default parameters: " + classErr.getMessage()); } }
From source file:info.magnolia.objectfactory.Classes.java
/** * Convenience/shortcut for {@link #newInstance(String, Object...)}, returning null both in case * of a ClassNotFoundException or if the class could not be instantiated. * (which could be related to the parameters, etc) *//*from w w w . ja v a2 s. c o m*/ public static <T> T quietNewInstance(String className, Object... params) { try { return Classes.<T>newInstance(className, params); } catch (ClassNotFoundException e) { log.warn("Couldn't find class with name {}", className); return null; } catch (MgnlInstantiationException e) { log.warn("Couldn't instantiate {}: {}", className, e.getMessage()); return null; } }