List of usage examples for java.lang NoClassDefFoundError NoClassDefFoundError
public NoClassDefFoundError(String s)
NoClassDefFoundError
with the specified detail message. From source file:org.carrot2.util.attribute.BindableDescriptorUtils.java
/** * @return Returns the descriptor class for a class marked with {@link Bindable}. * @throws IllegalArgumentException If the class is not annotated with {@link Bindable}. * @throws NoClassDefFoundError If the descriptor cannot be found. */// w w w.j ava 2 s . c o m @SuppressWarnings("unchecked") public static Class<? extends IBindableDescriptor> getDescriptorClass(Class<?> clazz) { if (clazz.getAnnotation(Bindable.class) == null) throw new IllegalArgumentException("Class not marked with @Bindable: " + clazz.getName()); ClassLoader cl = clazz.getClassLoader(); String descriptorClassName = getDescriptorClassName(clazz.getName()); try { return (Class<? extends IBindableDescriptor>) Class.forName(descriptorClassName, true, cl); } catch (ClassNotFoundException e) { throw new NoClassDefFoundError("Descriptor class not found: " + descriptorClassName); } }
From source file:org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader.java
protected Class<?> findClass(String name) throws ClassNotFoundException { try {/* w ww .j ava 2 s . com*/ return this.backingBundle.loadClass(name); } catch (ClassNotFoundException cnfe) { DebugUtils.debugClassLoading(backingBundle, name, null); throw new ClassNotFoundException( name + " not found from bundle [" + backingBundle.getSymbolicName() + "]", cnfe); } catch (NoClassDefFoundError ncdfe) { // This is almost always an error // This is caused by a dependent class failure, // so make sure we search for the right one. String cname = ncdfe.getMessage().replace('/', '.'); DebugUtils.debugClassLoading(backingBundle, cname, name); NoClassDefFoundError e = new NoClassDefFoundError(name + " not found from bundle [" + OsgiStringUtils.nullSafeNameAndSymName(backingBundle) + "]"); e.initCause(ncdfe); throw e; } }
From source file:org.kitodo.dataformat.access.MetsXmlElementAccess.java
/** * Creates an object of class XMLGregorianCalendar. Creating this * JAXB-specific class is quite complicated and has therefore been * outsourced to a separate method.//from ww w . j a v a2s . com * * @param gregorianCalendar * value of the calendar * @return an object of class XMLGregorianCalendar */ private static XMLGregorianCalendar convertDate(GregorianCalendar gregorianCalendar) { DatatypeFactory datatypeFactory; try { datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { String message = e.getMessage(); throw new NoClassDefFoundError(message != null ? message : "Implementation of DatatypeFactory not available or cannot be instantiated."); } return datatypeFactory.newXMLGregorianCalendar(gregorianCalendar); }
From source file:org.spongepowered.asm.mixin.transformer.MixinTransformer.java
@Override public byte[] transform(String name, String transformedName, byte[] basicClass) { if (basicClass == null) { return basicClass; }/* www.j a v a2 s . c o m*/ this.reEntranceCheck++; if (this.reEntranceCheck > 1) { this.detectReEntrance(); } if (!this.initDone) { this.initConfigs(); this.initDone = true; } try { SortedSet<MixinInfo> mixins = null; for (MixinConfig config : this.configs) { if (transformedName != null && transformedName.startsWith(config.getMixinPackage())) { throw new NoClassDefFoundError(String .format("%s is a mixin class and cannot be referenced directly", transformedName)); } if (config.hasMixinsFor(transformedName)) { if (mixins == null) { mixins = new TreeSet<MixinInfo>(); } // Get and sort mixins for the class mixins.addAll(config.getMixinsFor(transformedName)); } } if (mixins != null) { try { basicClass = this.applyMixins(transformedName, basicClass, mixins); } catch (InvalidMixinException th) { MixinConfig config = th.getMixin().getParent(); this.logger.log(config.isRequired() ? Level.FATAL : Level.WARN, String.format("Mixin failed applying %s -> %s: %s %s", th.getMixin(), transformedName, th.getClass().getName(), th.getMessage()), th); if (config.isRequired()) { throw new MixinApplyError( "Mixin [" + th.getMixin() + "] FAILED for REQUIRED config [" + config + "]", th); } th.printStackTrace(); } } return basicClass; } catch (Exception ex) { throw new MixinTransformerError("An unexpected critical error was encountered", ex); } finally { this.reEntranceCheck--; } }
From source file:org.springframework.security.config.SecurityNamespaceHandlerTests.java
@Test public void initDoesNotLogErrorWhenFilterChainProxyFailsToLoad() throws Exception { String className = "javax.servlet.Filter"; spy(ClassUtils.class); doThrow(new NoClassDefFoundError(className)).when(ClassUtils.class, "forName", eq(FILTER_CHAIN_PROXY_CLASSNAME), any(ClassLoader.class)); Log logger = mock(Log.class); SecurityNamespaceHandler handler = new SecurityNamespaceHandler(); ReflectionTestUtils.setField(handler, "logger", logger); handler.init();//from ww w . jav a 2 s .c o m verifyStatic(ClassUtils.class); ClassUtils.forName(eq(FILTER_CHAIN_PROXY_CLASSNAME), any(ClassLoader.class)); verifyZeroInteractions(logger); }
From source file:org.springframework.security.config.SecurityNamespaceHandlerTests.java
@Test public void filterNoClassDefFoundError() throws Exception { String className = "javax.servlet.Filter"; thrown.expect(BeanDefinitionParsingException.class); thrown.expectMessage("NoClassDefFoundError: " + className); spy(ClassUtils.class); doThrow(new NoClassDefFoundError(className)).when(ClassUtils.class, "forName", eq(FILTER_CHAIN_PROXY_CLASSNAME), any(ClassLoader.class)); new InMemoryXmlApplicationContext(XML_AUTHENTICATION_MANAGER + XML_HTTP_BLOCK); }
From source file:org.springframework.security.config.SecurityNamespaceHandlerTests.java
@Test public void filterNoClassDefFoundErrorNoHttpBlock() throws Exception { String className = "javax.servlet.Filter"; spy(ClassUtils.class); doThrow(new NoClassDefFoundError(className)).when(ClassUtils.class, "forName", eq(FILTER_CHAIN_PROXY_CLASSNAME), any(ClassLoader.class)); new InMemoryXmlApplicationContext(XML_AUTHENTICATION_MANAGER); // should load just fine since no http block }
From source file:org.wildfly.security.x500.cert.acme.AcmeClientSpiTest.java
private static void mockRetryAfter() { Class<?> classToMock;/*from w w w . ja va2 s . c o m*/ try { classToMock = Class.forName("org.wildfly.security.x500.cert.acme.AcmeClientSpi", true, AcmeAccount.class.getClassLoader()); } catch (ClassNotFoundException e) { throw new NoClassDefFoundError(e.getMessage()); } new MockUp<Object>(classToMock) { @Mock private long getRetryAfter(HttpURLConnection connection, boolean useDefaultIfHeaderNotPresent) throws AcmeException { return 0; } }; }