List of usage examples for java.lang ClassNotFoundException ClassNotFoundException
public ClassNotFoundException(String s)
ClassNotFoundException
with the specified detail message. From source file:org.bimserver.plugins.EclipsePluginClassloader.java
@Override protected Class<?> findClass(String name) throws ClassNotFoundException { String filename = name.replace(".", File.separator) + ".class"; if (loadedClasses.containsKey(filename)) { return loadedClasses.get(filename); }/*from www . j a v a2 s . c om*/ File classFile = new File(classFolder, filename); if (classFile.isFile()) { try { byte[] bytes = FileUtils.readFileToByteArray(classFile); Class<?> definedClass = defineClass(name, bytes, 0, bytes.length); if (definedClass != null) { loadedClasses.put(filename, definedClass); return definedClass; } } catch (IOException e) { LOGGER.error("", e); } } throw new ClassNotFoundException(name); }
From source file:org.spongepowered.asm.mixin.transformer.TreeInfo.java
/** * @param className//from ww w . j a v a 2 s . c om * @param runTransformers * @return Transformed class bytecode for the specified class */ static byte[] loadClass(String className, boolean runTransformers) throws ClassNotFoundException, IOException { className = className.replace('/', '.'); byte[] classBytes = null; if ((classBytes = TreeInfo.getClassBytes(className)) == null) { throw new ClassNotFoundException(String.format("The specified class '%s' was not found", className)); } if (runTransformers) { classBytes = TreeInfo.applyTransformers(className, classBytes); } return classBytes; }
From source file:com.chiorichan.plugin.loader.PluginClassLoader.java
Class<?> findClass(String name, boolean checkGlobal) throws ClassNotFoundException { if (name.startsWith("com.chiorichan.") && !name.startsWith("com.chiorichan.plugin.")) { throw new ClassNotFoundException(name); }//from w w w . jav a2 s . c om Class<?> result = classes.get(name); if (result == null) { if (checkGlobal) { result = loader.getClassByName(name); } if (result == null) { result = super.findClass(name); if (result != null) { loader.setClass(name, result); } } classes.put(name, result); } return result; }
From source file:org.apache.tomcat.util.net.SSLImplementation.java
public static SSLImplementation getInstance() throws ClassNotFoundException { for (int i = 0; i < implementations.length; i++) { try {/*from www. j av a 2s .co m*/ SSLImplementation impl = getInstance(implementations[i]); return impl; } catch (Exception e) { if (logger.isTraceEnabled()) logger.trace("Error creating " + implementations[i], e); } } // If we can't instantiate any of these throw new ClassNotFoundException("Can't find any SSL implementation"); }
From source file:net.ion.radon.cload.stores.ResourceStoreClassLoader.java
@Override protected Class<?> findClass(final String name) throws ClassNotFoundException { final Class<?> clazz = fastFindClass(name); if (clazz == null) { throw new ClassNotFoundException(name); }/*w ww. j a v a 2 s . c om*/ return clazz; }
From source file:com.github.wolf480pl.mias4j.core.runtime.BMClassLoader.java
@Override protected Class<?> findClass(String name) throws ClassNotFoundException { if (name.equals(BNAME)) { URL res = getParent().getParent().getResource(RNAME); // double getParent because FilteringClassLoader if (res == null) { throw new ClassNotFoundException(name + ": no " + RNAME); }// w ww.j a v a2 s .c o m InputStream is; try { is = res.openStream(); } catch (IOException e) { throw new ClassNotFoundException(name, e); } byte[] bytes; try { bytes = IOUtils.toByteArray(is); } catch (IOException e) { throw new ClassNotFoundException(name, e); } // TODO: Are we sure about this CodeSource? CodeSource cs = Bootstraps.class.getProtectionDomain().getCodeSource(); Package pkg = Bootstraps.class.getPackage(); if (pkg != null && getPackage(pkg.getName()) == null) { copyPackage(pkg, cs); } Class<?> c = defineClass(name, bytes, 0, bytes.length, cs); initHandle(c); return c; } else { throw new ClassNotFoundException(name); } }
From source file:org.eu.gasp.core.internal.PluginClassLoader.java
@Override protected Class<?> findClass(String name) throws ClassNotFoundException { try {/*from w w w .j a va2 s . c o m*/ final Class clazz = super.findClass(name); if (log.isDebugEnabled()) { log.debug("Class '" + name + "' loaded from super.findClass()"); } return clazz; } catch (ClassNotFoundException ignore) { } for (final PluginDependency pluginDependency : pluginDescriptor.getPluginDependencies()) { final ClassLoader classLoader = pluginRegistry.getClassLoader(pluginDependency.getPluginId(), pluginDependency.getVersion()); try { final Class clazz = classLoader.loadClass(name); if (log.isDebugEnabled()) { log.debug("Class '" + name + "' loaded from plugin class loader: " + pluginDependency.getPluginId()); } return clazz; } catch (ClassNotFoundException ignore) { } } try { final Class clazz = getParent().loadClass(name); if (log.isDebugEnabled()) { log.debug("Class '" + name + "' loaded from parent class loader"); } return clazz; } catch (ClassNotFoundException ignore) { } if (log.isDebugEnabled()) { log.debug("Unable to load class '" + name + "' from any class loaders"); } throw new ClassNotFoundException(name); }
From source file:com.github.wolf480pl.mias4j.util.AbstractTransformingClassLoader.java
@Override protected Class<?> findClass(String name) throws ClassNotFoundException { final String iname = toInternalName(name); final String rname = iname + ".class"; URL res = backend.getResource(rname); if (res == null) { throw new ClassNotFoundException(name + ": no " + rname); }//from ww w. j av a 2s . c o m URLConnection conn; InputStream is; try { conn = res.openConnection(); is = conn.getInputStream(); } catch (IOException e) { throw new ClassNotFoundException(name, e); } byte[] bytes; try { bytes = IOUtils.toByteArray(is); } catch (IOException e) { throw new ClassNotFoundException(name, e); } CodeSource cs = getCodeSourceAndDefinePackage(conn, rname, name); bytes = transform(name, bytes, cs); Class<?> c = defineClass(name, bytes, 0, bytes.length, cs); return c; }
From source file:org.eclipse.emf.mwe.internal.core.debug.processing.RuntimeHandlerManager.java
private void listenAndRegisterClasses() throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException { RegisterPackage packet = (RegisterPackage) connection.listenForPackage(RegisterPackage.class); String msg = null;//from w ww . j ava 2 s . c o m if (packet.type == RegisterPackage.HANDLERS) { RuntimeHandler handler = null; for (String className : packet.classNames) { final Class<?> clazz = ResourceLoaderFactory.createResourceLoader().loadClass(className); if (clazz == null) { msg = "Couldn't find " + className + " in the class path."; System.err.println(msg); throw new ClassNotFoundException(msg); } handler = (RuntimeHandler) clazz.newInstance(); handler.init(monitor, connection); handler.startListener(); } } else { ElementAdapter adapter = null; for (String className : packet.classNames) { final Class<?> clazz = ResourceLoaderFactory.createResourceLoader().loadClass(className); if (clazz == null) { msg = "Couldn't find " + className + " in the class path."; System.err.println(msg); throw new ClassNotFoundException(msg); } adapter = (ElementAdapter) clazz.newInstance(); monitor.addAdapter(adapter); } } }
From source file:com.vaadin.terminal.gwt.server.SpringApplicationOSGiServlet.java
@Override protected Application getNewApplication(HttpServletRequest request) throws ServletException { // Creates a new application instance try {//ww w . j av a 2 s.c o m // Retrieve the Spring ApplicationContext registered as a service ApplicationContext springContext = getApplicationContext(); if (!springContext.containsBean(beanParam)) { throw new ClassNotFoundException("No application bean found under name " + beanParam); } final Application application = (Application) springContext.getBean(beanParam); return application; } catch (ClassNotFoundException e) { throw new ServletException("getNewApplication failed", e); } }