List of usage examples for java.lang ClassNotFoundException ClassNotFoundException
public ClassNotFoundException(String s)
ClassNotFoundException
with the specified detail message. From source file:org.mule.module.launcher.application.CompositeApplicationClassLoader.java
protected Class<?> loadClass(ClassLoader classLoader, String s, boolean b) throws ClassNotFoundException { try {/*from w w w .j a va 2 s. c om*/ Method loadClassMethod = findDeclaredMethod(classLoader, "loadClass", String.class, boolean.class); return (Class<?>) loadClassMethod.invoke(classLoader, s, b); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(String.format("Error loading class '%s' from classloader '%s'", s, classLoader), e); } } throw new ClassNotFoundException(String.format("Cannot load class '%s'", s)); }
From source file:org.atricore.idbus.kernel.common.support.osgi.OsgiBundlespaceClassLoader.java
@Override protected Class<?> findClass(String name) throws ClassNotFoundException { Map<Bundle, OsgiBundleClassLoader> bundleClassLoaders = getBundleClassLoaders(); for (Bundle bundle : getBundles()) { if (canLoadResources(bundle)) { if (getPrioritizedBundles().contains(bundle) || containsClassPackage(bundle, name)) { try { return bundleClassLoaders.get(bundle).loadClass(name); } catch (ClassNotFoundException ex) { /// Continue searching in the next bundle. } catch (Throwable ex) { /// Catch any other exceptions which could be thrown by a bundle loading a class. }// w ww. jav a 2 s . c o m } } } if (getSupportingClassLoader() != null) { return getSupportingClassLoader().loadClass(name); } else { throw new ClassNotFoundException( String.format("Class '%s' could not be load from %s", name, getClass().getSimpleName())); } }
From source file:com.blackberry.bdp.test.utils.LocalZkServer.java
public LocalZkServer() throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException { String dataDirectory = System.getProperty("java.io.tmpdir"); dir = new File(dataDirectory, "zookeeper").getAbsoluteFile(); while (dir.exists()) { LOG.info("deleting {}", dir); FileUtils.deleteDirectory(dir);/*from w w w .j a v a2 s .c om*/ } server = new ZooKeeperServer(dir, dir, tickTime); // The class that we need changed name between CDH3 and CDH4, so let's check // for the right version here. try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxnFactory"); standaloneServerFactory = factoryClass.newInstance(); Method configure = factoryClass.getMethod("configure", InetSocketAddress.class, Integer.TYPE); configure.invoke(standaloneServerFactory, new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e) { LOG.info("Did not find NIOServerCnxnFactory"); try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxn$Factory"); Constructor<?> constructor = factoryClass.getConstructor(InetSocketAddress.class, Integer.TYPE); standaloneServerFactory = constructor.newInstance(new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e1) { LOG.info("Did not find NIOServerCnxn.Factory"); throw new ClassNotFoundException("Can't find NIOServerCnxnFactory or NIOServerCnxn.Factory"); } } }
From source file:com.blackberry.bdp.common.versioned.LocalZkServer.java
public LocalZkServer() throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException { String dataDirectory = System.getProperty("java.io.tmpdir"); dir = new File(dataDirectory, "zookeeper").getAbsoluteFile(); while (dir.exists()) { LOG.info("deleting {}", dir); FileUtils.deleteDirectory(dir);/*from w w w . j av a 2 s.c o m*/ } server = new ZooKeeperServer(dir, dir, tickTime); // The class that we need changed name between CDH3 and CDH4, so let's // check // for the right version here. try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxnFactory"); standaloneServerFactory = factoryClass.newInstance(); Method configure = factoryClass.getMethod("configure", InetSocketAddress.class, Integer.TYPE); configure.invoke(standaloneServerFactory, new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e) { LOG.info("Did not find NIOServerCnxnFactory"); try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxn$Factory"); Constructor<?> constructor = factoryClass.getConstructor(InetSocketAddress.class, Integer.TYPE); standaloneServerFactory = constructor.newInstance(new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e1) { LOG.info("Did not find NIOServerCnxn.Factory"); throw new ClassNotFoundException("Can't find NIOServerCnxnFactory or NIOServerCnxn.Factory"); } } }
From source file:org.apache.openjpa.jdbc.meta.strats.ClassNameDiscriminatorStrategy.java
public void loadSubclasses(JDBCStore store) throws SQLException, ClassNotFoundException { if (isFinal) { disc.setSubclassesLoaded(true);/*from w ww . j av a 2 s. c om*/ return; } Column col = disc.getColumns()[0]; DBDictionary dict = store.getDBDictionary(); JDBCFetchConfiguration fetch = store.getFetchConfiguration(); SQLBuffer select = dict.toSelect(new SQLBuffer(dict).append(col), fetch, new SQLBuffer(dict).append(col.getTable()), null, null, null, null, true, false, 0, Long.MAX_VALUE); Log log = disc.getMappingRepository().getLog(); if (log.isTraceEnabled()) log.trace(_loc.get("load-subs", col.getTable().getFullName())); ClassLoader loader = getClassLoader(store); Connection conn = store.getConnection(); PreparedStatement stmnt = null; ResultSet rs = null; try { stmnt = select.prepareStatement(conn); dict.setTimeouts(stmnt, fetch, false); rs = stmnt.executeQuery(); String className; while (rs.next()) { className = dict.getString(rs, 1); if (StringUtils.isEmpty(className)) throw new ClassNotFoundException( _loc.get("no-class-name", disc.getClassMapping(), col).getMessage()); Class.forName(className, true, loader); } disc.setSubclassesLoaded(true); } finally { if (rs != null) try { rs.close(); } catch (SQLException se) { } if (stmnt != null) try { stmnt.close(); } catch (SQLException se) { } try { conn.close(); } catch (SQLException se) { } } }
From source file:org.apache.axis2.deployment.DeploymentClassLoader.java
/** * Finds and loads the class with the specified name from the URL search * path. Any URLs referring to JAR files are loaded and opened as needed * until the class is found.//from w w w . j a v a 2s . c o m * * @param name the name of the class * @return the resulting class * @exception ClassNotFoundException if the class could not be found */ protected Class findClass(String name) throws ClassNotFoundException { Class clazz; try { clazz = super.findClass(name); } catch (ClassNotFoundException e) { byte raw[] = null; try { String completeFileName = name; /** * Replacing org.apache. -> org/apache/... */ completeFileName = completeFileName.replace('.', '/').concat(".class"); raw = getBytes(completeFileName); } catch (Exception ex) { // Fall through } if (raw == null) { throw new ClassNotFoundException("Class Not found : " + name); } clazz = defineClass(name, raw, 0, raw.length); } return clazz; }
From source file:org.ws13.vaadin.osgi.dm.app.SpringApplicationServlet.java
/** * Get the application class from the bean configured in Spring's context. * //from w w w.j a va2s.c o m * @see AbstractApplicationServlet#getApplicationClass() */ @Override protected Class<? extends Application> getApplicationClass() throws ClassNotFoundException { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); if (wac == null) { throw new ClassNotFoundException("Cannot get an handle on Spring's context. Is Spring running? " + "Check there's an org.springframework.web.context.ContextLoaderListener configured."); } String[] beanDefinitionNames = wac.getBeanDefinitionNames(); for (String string : beanDefinitionNames) { System.out.println("SpringApplicationServlet.getApplicationClass() " + string); } Application bean = wac.getBean(name, Application.class); if (bean == null) { throw new ClassNotFoundException("No application bean found under name " + name); } return bean.getClass(); }
From source file:gov.va.vinci.leo.tools.db.LeoDataSource.java
/** * Connect to the database./*from w w w . ja va 2 s . c om*/ * * @param driver Database driver class * @param url URL for the connection. * @param user Username. If null, the connection is made without using a username and password. * @param pwd Password if needed. * @throws ClassNotFoundException thrown if the JDBC driver cannot be found. * @throws SQLException thrown if there is an exception with the query or result set. */ protected void connect(String driver, String url, String user, String pwd) throws ClassNotFoundException, SQLException { if (DbUtils.loadDriver(driver)) { if (!StringUtils.isBlank(user)) { this.mConn = DriverManager.getConnection(url, user, pwd); } else { this.mConn = DriverManager.getConnection(url); } } else { throw new ClassNotFoundException("Driver not found: " + driver); } }
From source file:org.apache.wiki.util.ClassUtil.java
/** * Attempts to find a class from a collection of packages. This will first * attempt to find the class based on just the className parameter, but * should that fail, will iterate through the "packages" -list, prefixes * the package name to the className, and then tries to find the class * again./*from ww w . j a va2 s. c o m*/ * * @param packages A List of Strings, containing different package names. * @param className The name of the class to find. * @return The class, if it was found. * @throws ClassNotFoundException if this particular class cannot be found * from the list. */ public static Class<?> findClass(List<String> packages, List<String> externaljars, String className) throws ClassNotFoundException { if (!classLoaderSetup) { loader = setupClassLoader(externaljars); } try { return loader.loadClass(className); } catch (ClassNotFoundException e) { for (Iterator<String> i = packages.iterator(); i.hasNext();) { String packageName = i.next(); try { return loader.loadClass(packageName + "." + className); } catch (ClassNotFoundException ex) { // This is okay, we go to the next package. } } } throw new ClassNotFoundException("Class '" + className + "' not found in search path!"); }
From source file:com.liferay.arkadiko.bean.AKBeanDefinition.java
/** * Resolve bean class./*from w ww. ja v a 2 s. c o m*/ * * @param classLoader the class loader * @return the class * @throws ClassNotFoundException the class not found exception */ @Override public Class resolveBeanClass(ClassLoader classLoader) throws ClassNotFoundException { Object proxy = getProxy(); if (proxy == null) { throw new ClassNotFoundException(getBeanClassName()); } return proxy.getClass(); }