List of usage examples for java.lang ClassNotFoundException getMessage
public String getMessage()
From source file:org.apache.ivy.util.url.URLHandlerRegistry.java
/** * This method is used to get appropriate http downloader dependening on Jakarta Commons * HttpClient availability in classpath, or simply use jdk url handling in other cases. * //from w w w . j a v a 2 s.c o m * @return most accurate http downloader */ public static URLHandler getHttp() { try { Class.forName("org.apache.commons.httpclient.HttpClient"); // temporary fix for IVY-880: only use HttpClientHandler when // http-client-3.x is available Class.forName("org.apache.commons.httpclient.params.HttpClientParams"); Class handler = Class.forName("org.apache.ivy.util.url.HttpClientHandler"); Message.verbose("jakarta commons httpclient detected: using it for http downloading"); return (URLHandler) handler.newInstance(); } catch (ClassNotFoundException e) { Message.verbose("jakarta commons httpclient not found: using jdk url handling"); return new BasicURLHandler(); } catch (NoClassDefFoundError e) { Message.verbose("error occurred while loading jakarta commons httpclient: " + e.getMessage()); Message.verbose("Using jdk url handling instead."); return new BasicURLHandler(); } catch (InstantiationException e) { Message.verbose("couldn't instantiate HttpClientHandler: using jdk url handling"); return new BasicURLHandler(); } catch (IllegalAccessException e) { Message.verbose("couldn't instantiate HttpClientHandler: using jdk url handling"); return new BasicURLHandler(); } }
From source file:org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy.java
public static VertexProgramStrategy create(final Configuration configuration) { try {//from w w w. j a v a 2 s. c om final VertexProgramStrategy.Builder builder = VertexProgramStrategy.build(); for (final String key : (List<String>) IteratorUtils.asList(configuration.getKeys())) { if (key.equals(GRAPH_COMPUTER)) builder.graphComputer((Class) Class.forName(configuration.getString(key))); else if (key.equals(WORKERS)) builder.workers(configuration.getInt(key)); else if (key.equals(PERSIST)) builder.persist(GraphComputer.Persist.valueOf(configuration.getString(key))); else if (key.equals(RESULT)) builder.result(GraphComputer.ResultGraph.valueOf(configuration.getString(key))); else if (key.equals(VERTICES)) builder.vertices((Traversal) configuration.getProperty(key)); else if (key.equals(EDGES)) builder.edges((Traversal) configuration.getProperty(key)); else builder.configure(key, configuration.getProperty(key)); } return builder.create(); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
From source file:controllers.TestApplication.java
public static Result getTestNodesPrivateKey() { try {/* w ww. ja v a2 s. c o m*/ SSHKeyStore store = new SSHKeyStore(); SSHKey key = store.getKey(ConfigurationService.TEST_USER); if (key == null) { return ok(views.html.error.render("no cluster key found")); } return ok(key.getSSHPrivateKey()).as("text/plain"); } catch (ClassNotFoundException e) { return ok(views.html.error.render(e.getMessage())); } catch (IOException e) { return ok(views.html.error.render(e.getMessage())); } }
From source file:org.apache.axis2.jaxws.util.WSToolingUtils.java
/** * Retrieves the major version number of the WsGen class that we're using * //from ww w. j a va2s. co m * @return String * */ public static String getWsGenVersion() throws ClassNotFoundException, IOException { Class clazz = null; try { clazz = forName("com.sun.tools.ws.WsGen", false, getContextClassLoader(null)); } catch (ClassNotFoundException e1) { try { clazz = forName("com.sun.tools.internal.ws.WsGen", false, getContextClassLoader(null)); } catch (ClassNotFoundException e2) { if (log.isDebugEnabled()) { log.debug("Exception thrown from getWsGenVersion: " + e2.getMessage(), e2); } throw (ClassNotFoundException) e2; } } Properties p = new Properties(); try { p.load(clazz.getResourceAsStream("version.properties")); } catch (IOException ioex) { if (log.isDebugEnabled()) { log.debug("Exception thrown from getWsGenVersion: " + ioex.getMessage(), ioex); } throw (IOException) ioex.getCause(); } return (p.getProperty("major-version")); }
From source file:controllers.GoogleComputeEngineApplication.java
public static Result getClusterPrivateKey() { try {//from w w w.j av a 2 s. c om SSHKeyStore store = new SSHKeyStore(); SSHKey key = store.getKey(ConfigurationService.CLUSTER_USER); if (key == null) { return ok(views.html.error.render("no cluster key found")); } return ok(key.getSSHPrivateKey()).as("text/plain"); } catch (ClassNotFoundException e) { return ok(views.html.error.render(e.getMessage())); } catch (IOException e) { return ok(views.html.error.render(e.getMessage())); } }
From source file:com.github.gekoh.yagen.ddl.CoreDDLGenerator.java
public static DDLGenerator.Profile createProfileFrom(String[] args) throws ParseException { DDLGenerator.Profile profile = null; CommandLineParser clp = new GnuParser(); CommandLine cl = clp.parse(OPTIONS, args); try {/* ww w . java 2 s. c om*/ if (cl.hasOption(PARAM_PROFILE_PROVIDER_CLASS)) { profile = ((ProfileProvider) Class.forName(cl.getOptionValue(PARAM_PROFILE_PROVIDER_CLASS)) .newInstance()).getProfile(cl.getOptionValue(PARAM_PROFILE_NAME)); } else { profile = new DDLGenerator.Profile(cl.getOptionValue(PARAM_PROFILE_NAME)); } if (cl.hasOption(PARAM_OUTPUT_FILENAME)) { profile.setOutputFile(cl.getOptionValue(PARAM_OUTPUT_FILENAME)); } if (cl.hasOption(PARAM_PERSISTENCE_UNIT_NAME)) { profile.setPersistenceUnitName(cl.getOptionValue(PARAM_PERSISTENCE_UNIT_NAME)); } if (cl.hasOption(PARAM_PERSISTENCE_XML_LIST)) { profile.addPersistenceFile(cl.getOptionValue(PARAM_PERSISTENCE_XML_LIST).split(";[\\s]*")); } if (cl.hasOption(PARAM_HEADER_DDLS_LIST)) { profile.addHeaderDdlFile(cl.getOptionValue(PARAM_HEADER_DDLS_LIST).split(";[\\s]*")); } if (cl.hasOption(PARAM_ADDITIONAL_DDLS_LIST)) { profile.addDdlFile(cl.getOptionValue(PARAM_ADDITIONAL_DDLS_LIST).split(";[\\s]*")); } if (cl.hasOption(PARAM_DISABLE_FKS)) { profile.setDisableFKs(true); } if (cl.hasOption(PARAM_NO_HISTORY_GENERATION)) { profile.setNoHistory(true); } if (cl.hasOption(PARAM_REGEX_RENDER_ONLY_ENTITIES)) { profile.setOnlyRenderEntitiesRegex(cl.getOptionValue(PARAM_REGEX_RENDER_ONLY_ENTITIES)); } } catch (ClassNotFoundException e) { throw new IllegalStateException( "cannot instantiate profile provider class " + cl.getOptionValue(PARAM_PROFILE_PROVIDER_CLASS)); } catch (Exception e) { throw new IllegalStateException("error setting up generator profile: " + e.getMessage(), e); } return profile; }
From source file:org.chiba.xml.xforms.CustomElementFactory.java
private static Map getCustomActionElementsConfig() { try {// ww w.j a v a2s .co m Map elementClassNames = Config.getInstance().getCustomActionsElements(); 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); 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:org.chiba.xml.xforms.CustomElementFactory.java
/** * Loads the configuration for custom elements. * //from w w w.j ava2 s . c o 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); 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:de.xirp.plugin.PluginLoader.java
/** * Checks if the given plugin needs other plugins to run. * //www. j a v a 2 s . com * @param plugin * plugin to check * @param jarList * list of jar files on the class path * @param loader * the current class loader used to check if a class is * available * @return <code>true</code> if all other Plugins needed by this * Plugin are available * @see IPlugable#requiredLibs() */ @SuppressWarnings("unchecked") private static boolean checkNeeds(IPlugable plugin, ClassLoader loader, List<String> jarList) { if (plugin == null) { return true; } List<String> req = plugin.requiredLibs(); if (req == null) { return true; } boolean ret = true; for (String claas : req) { if (claas.endsWith(".jar")) { //$NON-NLS-1$ if (!jarList.contains(claas)) { ret &= false; logClass.warn(I18n.getString("PluginLoader.log.removingPluginBecauseOfMissingLib", //$NON-NLS-1$ plugin.getName(), claas) + Constants.LINE_SEPARATOR); } } else if (!currentPluginList.contains(claas)) { boolean hasClass = true; try { loader.loadClass(claas); } catch (ClassNotFoundException e) { logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$ hasClass = false; } if (!hasClass) { logClass.warn(I18n.getString("PluginLoader.log.removingPluginBecauseOfMissingLib", //$NON-NLS-1$ plugin.getName(), claas) + Constants.LINE_SEPARATOR); ret &= false; break; } } else { refs.put(claas, plugin.getInfo().getMainClass()); } } return ret; }
From source file:it.jnrpe.utils.PluginRepositoryUtil.java
/** * Parse an XML plugin definition.//from w ww . j a v a 2 s . c o m * * @param cl * The classloader to be used to load classes * @param plugin * The plugin XML element * @return the parsed plugin definition * @throws PluginConfigurationException * - */ @SuppressWarnings("rawtypes") private static PluginDefinition parsePluginDefinition(final ClassLoader cl, final Element plugin) throws PluginConfigurationException { // Check if the plugin definition is inside its own file if (getAttributeValue(plugin, "definedIn", false) != null) { StreamManager sm = new StreamManager(); String sFileName = getAttributeValue(plugin, "definedIn", false); try { InputStream in = sm.handle(cl.getResourceAsStream(sFileName)); return parseXmlPluginDefinition(cl, in); } finally { sm.closeAll(); } } String pluginClass = getAttributeValue(plugin, "class", true); Class clazz; try { clazz = LoadedClassCache.getClass(cl, pluginClass); if (!IPluginInterface.class.isAssignableFrom(clazz)) { throw new PluginConfigurationException("Specified class '" + clazz.getName() + "' in the plugin.xml file does not implement " + "the IPluginInterface interface"); } if (isAnnotated(clazz)) { return loadFromPluginAnnotation(clazz); } } catch (ClassNotFoundException e) { throw new PluginConfigurationException(e.getMessage(), e); } // The class is not annotated not has an external definition file... // Loading from current xml file... String sDescription = getAttributeValue(plugin, "description", false); @SuppressWarnings("unchecked") PluginDefinition pluginDef = new PluginDefinition(getAttributeValue(plugin, "name", true), sDescription, clazz); parseCommandLine(pluginDef, plugin); return pluginDef; }