List of usage examples for java.lang ClassNotFoundException getMessage
public String getMessage()
From source file:org.apache.juddi.cryptor.CryptorFactory.java
private static synchronized Cryptor createCryptor() { if (cryptor != null) { return cryptor; }/* w w w. j a va 2 s . c om*/ // grab class name of the Cryptor implementation to create String className = Property.DEFAULT_CRYPTOR; try { // grab class name of the Authenticator implementation to create className = AppConfig.getConfiguration().getString(Property.JUDDI_CRYPTOR, Property.DEFAULT_CRYPTOR); } catch (ConfigurationException ce) { log.error("Configuration exception occurred retrieving: " + Property.JUDDI_CRYPTOR, ce); } // write the Cryptor implementation name to the log log.debug("Cryptor Implementation = " + className); Class<?> cryptorClass = null; try { // Use Loader to locate & load the Cryptor implementation cryptorClass = ClassUtil.forName(className, CryptorFactory.class); } catch (ClassNotFoundException e) { log.error("The specified Cryptor class '" + className + "' was not found in classpath."); log.error(e); } if (cryptorClass != null) { try { // try to instantiate the Cryptor implementation cryptor = (Cryptor) cryptorClass.newInstance(); } catch (Exception e) { log.error("Exception while attempting to instantiate the implementation of Cryptor: " + cryptorClass.getName() + "\n" + e.getMessage()); log.error(e); } } return cryptor; }
From source file:org.apache.flink.client.FlinkYarnSessionCli.java
public static AbstractFlinkYarnClient getFlinkYarnClient() { AbstractFlinkYarnClient yarnClient;/*from w w w . j a va 2 s . c o m*/ try { Class<? extends AbstractFlinkYarnClient> yarnClientClass = Class .forName("org.apache.flink.yarn.FlinkYarnClient").asSubclass(AbstractFlinkYarnClient.class); yarnClient = InstantiationUtil.instantiate(yarnClientClass, AbstractFlinkYarnClient.class); } catch (ClassNotFoundException e) { System.err.println("Unable to locate the Flink YARN Client. " + "Please ensure that you are using a Flink build with Hadoop2/YARN support. Message: " + e.getMessage()); e.printStackTrace(System.err); return null; // make it obvious } return yarnClient; }
From source file:org.apache.torque.generator.configuration.source.SourceTransformerSaxHandler.java
/** * Creates an instance of a transformer. * * @param className the name of the transformer to be created. * * @return the instance of the transformer, not null. * * @throws ExceptionInInitializerError if an error occurs in the * initializer of the transformer. * @throws LinkageError if the linkage fails. * @throws SAXException if any other error occurs during instantiation * of the class.//w ww . ja v a 2 s . co m */ private static SourceTransformer createJavaSourceTransformer(String className) throws SAXException { Class<?> transformerClass; try { transformerClass = Class.forName(className); } catch (ClassNotFoundException e) { throw new SAXException( "Error while initializing a source transformer :" + " Could not load class " + className, e); } catch (ExceptionInInitializerError e) { log.error("Error while initializing a source transformer :" + " Could not initialize class " + className + " : " + e.getMessage()); throw e; } catch (LinkageError e) { log.error("Error while initializing a source transformer :" + " Could not link class " + className + " : " + e.getMessage()); throw e; } SourceTransformer result; try { Constructor<?> constructor = transformerClass.getConstructor(); result = (SourceTransformer) constructor.newInstance(); } catch (NoSuchMethodException e) { throw new SAXException("Error while instantiating a source transformer :" + " The class " + className + " has no default constructor", e); } catch (ClassCastException e) { throw new SAXException("Error while instantiating a source transformer :" + " The class " + className + " is not an instance of " + SourceTransformer.class.getName(), e); } catch (IllegalAccessException e) { throw new SAXException("Error while instantiating a source transformer :" + " The constructor of class " + className + " could not be accessed", e); } catch (InvocationTargetException e) { throw new SAXException("Error while instantiating a source transformer :" + " The constructor of class " + className + " could not be called", e); } catch (InstantiationException e) { throw new SAXException("Error while instantiating a source transformer :" + " The class " + className + " represents an abstract class, " + "an interface, an array class, a primitive type, " + "or void, or the class has no parameterless constructor, " + "or the instantiation fails for some other reason.", e); } catch (SecurityException e) { throw new SAXException("Error while instantiating a source transformer :" + " The security manager denies instantiation of the class " + className, e); } return result; }
From source file:com.extjs.djn.ioc.servlet.BaseDirectJNgineServlet.java
private static List<Class<?>> getClasses(String classes) { assert classes != null; List<Class<?>> result = new ArrayList<Class<?>>(); if (StringUtils.isEmpty(classes)) { return result; }//from w w w . j ava2 s. co m List<String> classNames = StringUtils.getNonBlankValues(classes, VALUES_SEPARATOR); for (String className : classNames) { try { Class<?> cls = Class.forName(className); result.add(cls); } catch (ClassNotFoundException ex) { logger.fatal(ex.getMessage(), ex); ServletConfigurationException e = ServletConfigurationException.forClassNotFound(className, ex); throw e; } } return result; }
From source file:BrowserLauncher.java
/** * Called by a static initializer to load any classes, fields, and methods required at runtime * to locate the user's web browser./*from w w w .ja va2 s . c o m*/ * @return <code>true</code> if all intialization succeeded * <code>false</code> if any portion of the initialization failed */ private static boolean loadClasses() { switch (jvm) { case MRJ_2_0: try { Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); Class aeClass = Class.forName("com.apple.MacOS.ae"); aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { int.class }); appleEventConstructor = appleEventClass.getDeclaredConstructor( new Class[] { int.class, int.class, aeTargetClass, int.class, int.class }); aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class }); makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[] { String.class }); putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[] { int.class, aeDescClass }); sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] {}); Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); keyDirectObject = (Integer) keyDirectObjectField.get(null); Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID"); kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID"); kAnyTransactionID = (Integer) anyTransactionIDField.get(null); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_2_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); kSystemFolderType = systemFolderField.get(null); findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass }); getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class }); getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (SecurityException se) { errorMessage = se.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_0: try { Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); Constructor constructor = linker.getConstructor(new Class[] { Class.class }); linkage = constructor.newInstance(new Object[] { BrowserLauncher.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (InvocationTargetException ite) { errorMessage = ite.getMessage(); return false; } catch (InstantiationException ie) { errorMessage = ie.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } break; default: break; } return true; }
From source file:org.apache.juddi.v3.client.cryptor.CryptorFactory.java
/** * Returns a crypto provider with the matching classname, throws if not * possible//www .j a v a 2 s .c o m * * @param className * @return a Cryptor instance * @throws Exception */ public static Cryptor getCryptor(String className) throws Exception { if (cache.containsKey(className)) { return cache.get(className); } Class<?> cryptorClass = null; try { // Use Loader to locate & load the Cryptor implementation cryptorClass = ClassUtil.forName(className, CryptorFactory.class); } catch (ClassNotFoundException e) { log.error("The specified Cryptor class '" + className + "' was not found in classpath."); log.error(e); throw e; } try { // try to instantiate the Cryptor implementation cryptor = (Cryptor) cryptorClass.newInstance(); cache.put(className, cryptor); } catch (Exception e) { log.error("Exception while attempting to instantiate the implementation of Cryptor: " + cryptorClass.getName() + "\n" + e.getMessage()); log.error(e); throw e; } return cryptor; }
From source file:org.apache.juddi.v3.client.cryptor.CryptorFactory.java
private static synchronized Cryptor createCryptor() { if (cryptor != null) { return cryptor; }//from w ww . j a va 2s . co m // grab class name of the Cryptor implementation to create String className = Property.DEFAULT_CRYPTOR; // write the Cryptor implementation name to the log log.debug("Cryptor Implementation = " + className); Class<?> cryptorClass = null; try { // Use Loader to locate & load the Cryptor implementation cryptorClass = ClassUtil.forName(className, CryptorFactory.class); } catch (ClassNotFoundException e) { log.error("The specified Cryptor class '" + className + "' was not found in classpath."); log.error(e); } if (cryptorClass != null) { try { // try to instantiate the Cryptor implementation cryptor = (Cryptor) cryptorClass.newInstance(); } catch (Exception e) { log.error("Exception while attempting to instantiate the implementation of Cryptor: " + cryptorClass.getName() + "\n" + e.getMessage()); log.error(e); } } return cryptor; }
From source file:info.magnolia.cms.gui.dialog.DialogFactory.java
/** * Get a instance by the control type name. Those name class mappings are configured in the admin interface * configuration./*from w w w . j a v a2 s .c om*/ * @param request * @param response * @param storageNode the node holding the data (can be null) * @param configNode the node holding the configuration (can be null) * @param controlType the name of the control * @return the conrol * @throws RepositoryException */ public static DialogControl getDialogControlInstanceByName(HttpServletRequest request, HttpServletResponse response, Content storageNode, Content configNode, String controlType) throws RepositoryException { Class dialogClass = (Class) controls.get(controlType); if (dialogClass == null) { try { dialogClass = Class.forName(controlType); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Unknown control type: \"" + controlType + "\""); //$NON-NLS-1$ //$NON-NLS-2$ } } DialogControl control = null; try { control = (DialogControl) dialogClass.newInstance(); } catch (Exception e) { // should never happen throw new NestableRuntimeException("Unable to instantiate " //$NON-NLS-1$ + dialogClass + " due to: InstantiationException - " //$NON-NLS-1$ + e.getMessage()); } control.init(request, response, storageNode, configNode); return control; }
From source file:org.apache.juddi.v3.auth.AuthenticatorFactory.java
/** * Returns a new instance of a Authenticator. * /* w ww .j av a 2 s . co m*/ * @return Authenticator */ private static synchronized Authenticator createAuthenticator() { if (auth != null) return auth; String className = DEFAULT_IMPL; try { // grab class name of the Authenticator implementation to create className = AppConfig.getConfiguration().getString(Property.JUDDI_AUTHENTICATOR, DEFAULT_IMPL); } catch (ConfigurationException ce) { log.error("Configuration exception occurred retrieving: " + Property.JUDDI_AUTHENTICATOR); } // write the Authenticator implementation name to the log log.debug("Authenticator Implementation = " + className); Class<?> authClass = null; try { // Use Loader to locate & load the Authenticator implementation authClass = ClassUtil.forName(className, AuthenticatorFactory.class); } catch (ClassNotFoundException e) { log.error("The specified Authenticator class '" + className + "' was not found in classpath."); log.error(e); } try { if (authClass != null) { // try to instantiate the Authenticator implementation auth = (Authenticator) authClass.newInstance(); } else { log.error("Could not load " + className + " authClass is null"); } } catch (Exception e) { log.error("Exception while attempting to instantiate the implementation of Authenticator: " + className + "\n" + e.getMessage()); log.error(e); } return auth; }
From source file:com.inamik.template.util.ClassLoaderUtil.java
/** * createNewInstance - Create a new instance of the specified class. * <p>//from www.j a va2 s . co m * This method first tries to create the new instance using the standard * class loader. If that fails, it then tries using the local class * loader. * * @param className The name of the class to instantiate. * @return New instance of the specified class, or null if the class could * not be found or instantiated. * * @see #getStandardClassLoader() * @see #getLocalClassLoader() */ public static Object createNewInstance(final String className) { if (className == null) { throw new NullPointerException("className"); } Class clazz; Object newInstance; try { clazz = Class.forName(className, true, getStandardClassLoader()); } catch (ClassNotFoundException e) { try { clazz = Class.forName(className, true, getLocalClassLoader()); } catch (ClassNotFoundException ex) { if (LOG.isWarnEnabled()) LOG.warn("Unable to find class '" + className + "'"); return null; } } try { newInstance = clazz.newInstance(); } catch (IllegalAccessException e) { if (LOG.isWarnEnabled()) LOG.warn("Unable to load class '" + className + "'. Cause was " + e.getMessage(), e); return null; } catch (InstantiationException e) { if (LOG.isWarnEnabled()) LOG.warn("Unable to load class '" + className + "'. Cause was " + e.getMessage(), e); return null; } return newInstance; }