List of usage examples for java.lang ClassNotFoundException getMessage
public String getMessage()
From source file:org.apache.tinkerpop.gremlin.spark.structure.io.InputOutputHelper.java
public static HadoopGraph getOutputGraph(final Configuration configuration, final GraphComputer.ResultGraph resultGraph, final GraphComputer.Persist persist) { try {// w w w . j ava 2 s .c o m final HadoopConfiguration hadoopConfiguration = new HadoopConfiguration(configuration); final BaseConfiguration newConfiguration = new BaseConfiguration(); newConfiguration.copy(org.apache.tinkerpop.gremlin.hadoop.structure.io.InputOutputHelper .getOutputGraph(configuration, resultGraph, persist).configuration()); if (resultGraph.equals(GraphComputer.ResultGraph.NEW) && hadoopConfiguration.containsKey(Constants.GREMLIN_SPARK_GRAPH_OUTPUT_RDD)) { newConfiguration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_INPUT_FORMAT, InputRDDFormat.class.getCanonicalName()); //newConfiguration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_OUTPUT_FORMAT, OutputRDDFormat.class.getCanonicalName()); newConfiguration.setProperty(Constants.GREMLIN_SPARK_GRAPH_INPUT_RDD, InputOutputHelper .getInputFormat((Class) Class.forName( hadoopConfiguration.getString(Constants.GREMLIN_SPARK_GRAPH_OUTPUT_RDD))) .getCanonicalName()); } return HadoopGraph.open(newConfiguration); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
From source file:com.ecyrd.jspwiki.util.Serializer.java
/** * Deserializes a Base64-encoded String into a HashMap. Both the keys and values * must implement {@link java.io.Serializable}. * @param rawString the String contents containing the map to be deserialized * @return the attributes, parsed into a Map * @throws IOException if the contents cannot be parsed for any reason *//* w w w . java 2 s . co m*/ @SuppressWarnings("unchecked") public static Map<String, ? extends Serializable> deserializeFromBase64(String rawString) throws IOException { // Decode from Base64-encoded String to byte array byte[] decodedBytes = Base64.decodeBase64(rawString.getBytes("UTF-8")); // Deserialize from the input stream to the Map InputStream bytesIn = new ByteArrayInputStream(decodedBytes); ObjectInputStream in = new ObjectInputStream(bytesIn); HashMap<String, Serializable> attributes; try { attributes = (HashMap<String, Serializable>) in.readObject(); } catch (ClassNotFoundException e) { throw new IOException("Could not deserialiaze user profile attributes. Reason: " + e.getMessage()); } finally { in.close(); } return attributes; }
From source file:com.wavemaker.commons.classloader.ClassLoaderUtils.java
/** * Loads class specified by className, using passed ClassLoader. *///from w w w . j a va 2 s .c o m public static Class<?> loadClass(String className, boolean initialize, ClassLoader loader) { try { Class<?> rtn = TypeConversionUtils.primitiveForName(className); if (rtn == null) { // On Windows, if the class has been loaded from a jar, this // may hold an open reference to the jar. rtn = Class.forName(className, initialize, loader); } return rtn; } catch (ClassNotFoundException ex) { String s = ex.getMessage(); if (s == null || s.equals("")) { s = "Cannot find class " + className; } throw new WMRuntimeException(s, ex); } }
From source file:de.micromata.tpsb.doc.renderer.RendererClassUtils.java
public static <T> T loadClass(String name, Class<T> expected) { try {//from w w w . jav a2 s. co m return (T) getRendererClassLoader().loadClass(name).newInstance(); } catch (ClassNotFoundException ex) { throw new RuntimeException("Cannot load class: " + name + "; " + ex.getMessage(), ex); } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException(ex); } catch (NoClassDefFoundError ex) { throw ex; } }
From source file:eu.leads.processor.planner.ClassUtil.java
private static void findClasses(Set<Class> matchedClassSet, File root, File file, boolean includeJars, Class type, String packageFilter) { if (file.isDirectory()) { for (File child : file.listFiles()) { findClasses(matchedClassSet, root, child, includeJars, type, packageFilter); }// ww w .j a v a 2 s. 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 (!clazz.isInterface() && isMatch(type, clazz)) { matchedClassSet.add(clazz); } } catch (ClassNotFoundException e) { LOG.error(e.getMessage(), e); } } } } } 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 (!clazz.isInterface() && isMatch(type, clazz)) { matchedClassSet.add(clazz); } } catch (ClassNotFoundException e) { LOG.error(e.getMessage(), e); } // } } } }
From source file:Main.java
/** * Returns a {@code Class} object which represents the class with * the given name. The name should be the name of a non-primitive * class, as described in the {@link Class class definition}. * Primitive types can not be found using this method; use {@code * int.class} or {@code Integer.TYPE} instead. * * @param className// w w w . j a va2 s . co m * @return */ public static Class<?> forName(String className) { try { return _forName(className); } catch (ClassNotFoundException e) { throw new IllegalStateException(e.getMessage(), e); } }
From source file:org.apache.jasper.security.SecurityClassLoad.java
public static void securityClassLoad(ClassLoader loader) { if (System.getSecurityManager() == null) { return;//w ww. j av a 2s . com } String basePackage = "org.apache.jasper."; try { loader.loadClass(basePackage + "runtime.JspFactoryImpl$PrivilegedGetPageContext"); loader.loadClass(basePackage + "runtime.JspFactoryImpl$PrivilegedReleasePageContext"); loader.loadClass(basePackage + "runtime.JspRuntimeLibrary"); loader.loadClass(basePackage + "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper"); loader.loadClass(basePackage + "runtime.ServletResponseWrapperInclude"); loader.loadClass(basePackage + "runtime.TagHandlerPool"); loader.loadClass(basePackage + "runtime.JspFragmentHelper"); loader.loadClass(basePackage + "runtime.ProtectedFunctionMapper"); loader.loadClass(basePackage + "runtime.ProtectedFunctionMapper$1"); loader.loadClass(basePackage + "runtime.ProtectedFunctionMapper$2"); loader.loadClass(basePackage + "runtime.ProtectedFunctionMapper$3"); loader.loadClass(basePackage + "runtime.ProtectedFunctionMapper$4"); loader.loadClass(basePackage + "runtime.PageContextImpl"); loader.loadClass(basePackage + "runtime.PageContextImpl$1"); loader.loadClass(basePackage + "runtime.PageContextImpl$2"); loader.loadClass(basePackage + "runtime.PageContextImpl$3"); loader.loadClass(basePackage + "runtime.PageContextImpl$4"); loader.loadClass(basePackage + "runtime.PageContextImpl$5"); loader.loadClass(basePackage + "runtime.PageContextImpl$6"); loader.loadClass(basePackage + "runtime.PageContextImpl$7"); loader.loadClass(basePackage + "runtime.PageContextImpl$8"); loader.loadClass(basePackage + "runtime.PageContextImpl$9"); loader.loadClass(basePackage + "runtime.PageContextImpl$10"); loader.loadClass(basePackage + "runtime.PageContextImpl$11"); loader.loadClass(basePackage + "runtime.PageContextImpl$12"); loader.loadClass(basePackage + "runtime.PageContextImpl$13"); loader.loadClass(basePackage + "runtime.JspContextWrapper"); loader.loadClass(basePackage + "servlet.JspServletWrapper"); loader.loadClass(basePackage + "runtime.JspWriterImpl$1"); } catch (ClassNotFoundException ex) { System.out.println("Jasper SecurityClassLoad preload of class failed: " + ex.getMessage()); log.error("SecurityClassLoad", ex); } }
From source file:org.apache.ws.security.saml.SAMLIssuerFactory.java
private static SAMLIssuer loadClass(String samlClassName, Properties properties) { Class samlIssuerClass = null; SAMLIssuer samlIssuer = null;//from ww w.j a v a2s . c o m try { // instruct the class loader to load the crypto implementation samlIssuerClass = Loader.loadClass(samlClassName); } catch (ClassNotFoundException ex) { if (log.isDebugEnabled()) { log.debug(ex.getMessage(), ex); } throw new RuntimeException(samlClassName + " Not Found", ex); } log.info("Using Crypto Engine [" + samlClassName + "]"); try { Class[] classes = new Class[] { Properties.class }; Constructor c = samlIssuerClass.getConstructor(classes); samlIssuer = (SAMLIssuer) c.newInstance(new Object[] { properties }); return samlIssuer; } catch (java.lang.Exception ex) { if (log.isDebugEnabled()) { log.debug(ex.getMessage(), ex); } } try { // try to instantiate the Crypto subclass samlIssuer = (SAMLIssuer) samlIssuerClass.newInstance(); return samlIssuer; } catch (java.lang.Exception ex) { if (log.isDebugEnabled()) { log.debug(ex.getMessage(), ex); } throw new RuntimeException(samlClassName + " cannot create instance", ex); } }
From source file:com.products.products.java
private static Connection getConnection() { Connection conn = null;/* w w w . ja v a 2s .co m*/ try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { System.err.println("JDBC Driver Not Found: " + ex.getMessage()); } try { String jdbc = "jdbc:mysql://ipro.lambton.on.ca/inventory"; conn = DriverManager.getConnection(jdbc, "products", "products"); } catch (SQLException ex) { System.err.println("Failed to Connect: " + ex.getMessage()); } return conn; }
From source file:com.alibaba.dragoon.patrol.PatrolUtils.java
public static void registerMBean(boolean useJndiDataSource, ClassLoader containerClassLoader, boolean springStatEnable, boolean jdbcStatEnable, boolean uriStatEnable, boolean log4jStatEnable, boolean napoliStatEnable, boolean napoliMQServerStatEnable) { JMXUtils.register(BEAN_NAME_KV_STATS, KVStatManager.getInstance()); // JMXUtils.register(BEAN_NAME_BROWSER_STATS, BrowserStatManager.getInstance()); if (springStatEnable) { JMXUtils.register(BEAN_NAME_SPRING_STAT, SpringStatManager.getInstance()); JMXUtils.register(BEAN_NAME_SPRING_METHOD_STAT, SpringStatManager.getInstance().getMethodStat()); JMXUtils.register(BEAN_NAME_SPRING_IBATIS_STAT, SpringStatManager.getInstance().getIbatisStat()); }// w w w . j a v a2 s .c o m if (uriStatEnable) { JMXUtils.register(BEAN_NAME_WEB_STAT, WebStatisticManager.getInstance()); } if (log4jStatEnable) { JMXUtils.register(BEAN_NAME_LOG_STAT, LogStatManager.getInstance()); // TODO remove it JMXUtils.register(BEAN_NAME_EXCEPTION, LogStatManager.getInstance()); // } JMXUtils.register(BEAN_NAME_TRACE, TraceManager.getInstance()); if (jdbcStatEnable) { if (useJndiDataSource) { try { Class<?> clazz = null; try { clazz = containerClassLoader.loadClass("com.alibaba.druid.stat.JdbcStatManager"); } catch (ClassNotFoundException ex) { LOG.warn(ex.getMessage(), ex); } if (clazz != null) { Object inst = clazz.getMethod("getInstance").invoke(null); JMXUtils.register(BEAN_NAME_JDBC_STAT, inst); Object connStat = clazz.getMethod("getConnectionstat").invoke(inst); JMXUtils.register(BEAN_NAME_JDBC_CONNECT_STAT, connStat); Object statementStat = clazz.getMethod("getStatementStat").invoke(inst); JMXUtils.register(BEAN_NAME_JDBC_STATEMENT_STAT, statementStat); Object resultSetStat = clazz.getMethod("getResultSetStat").invoke(inst); JMXUtils.register(BEAN_NAME_JDBC_RESULTSET_STAT, resultSetStat); Class<?> traceClazz = containerClassLoader .loadClass("com.alibaba.druid.stat.JdbcTraceManager"); Object traceInst = traceClazz.getMethod("getInstance").invoke(null); JMXUtils.register(BEAN_NAME_JDBC_TRACE, traceInst); Class<?> dataSourceStatManagerClazz = containerClassLoader .loadClass("com.alibaba.druid.stat.DruidDataSourceStatManager"); Object dataSourceStatManagerInst = dataSourceStatManagerClazz.getMethod("getInstance") .invoke(null); JMXUtils.register(BEAN_NAME_DATASOURCE_STAT, dataSourceStatManagerInst); } else { registerJDBCMBean(); } } catch (Exception ex) { LOG.error("register jdbc stat error", ex); } } else { registerJDBCMBean(); } } // added by chris if (napoliStatEnable) { JMXUtils.register(BEAN_NAME_NAPOLI_STAT, NapoliStatManager.getInstance()); } if (napoliMQServerStatEnable) { JMXUtils.register(BEAN_NAME_NAPOLI_MQSERVER_STAT, NapoliMQServerStatManager.getInstance()); } }