Skip to content

Instantly share code, notes, and snippets.

@tarilabs
Last active July 13, 2016 07:01
Show Gist options
  • Save tarilabs/d5d21656b4f0e2a7baec1ef9817b3dbc to your computer and use it in GitHub Desktop.
Save tarilabs/d5d21656b4f0e2a7baec1ef9817b3dbc to your computer and use it in GitHub Desktop.
@Test
public void testMacOSXClassLoaderBehavior() throws Exception {
final ClassTypeResolver resolver = new ClassTypeResolver( new HashSet(), Thread.currentThread().getContextClassLoader() );
resolver.addImport("org.drools.core.test.model.*");
assertEquals( org.drools.core.test.model.Cheese.class,
resolver.resolveType( "Cheese" ) );
try {
resolver.resolveType( "cheese" ); // <<- on Mac/OSX throws NoClassDefFoundError which escapes the try/catch and fail the test.
fail( "the type cheese (lower-case c) should not exists at all" );
} catch ( ClassNotFoundException e) {
// swallow as this should be thrown
}
}
java.lang.NoClassDefFoundError: mssp/io/model/user (wrong name: mssp/io/model/User)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at org.drools.core.common.ProjectClassLoader.internalLoadClass(ProjectClassLoader.java:162)
at org.drools.core.common.ProjectClassLoader.loadClass(ProjectClassLoader.java:141)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.drools.core.base.ClassTypeResolver.importClass(ClassTypeResolver.java:302)
at org.drools.core.base.ClassTypeResolver.getClassFromImports(ClassTypeResolver.java:254)
at org.drools.core.base.ClassTypeResolver.resolveType(ClassTypeResolver.java:201)
at org.drools.core.base.ClassTypeResolver.resolveType(ClassTypeResolver.java:130)
at org.drools.compiler.rule.builder.PatternBuilder.createDeclarationForOperator(PatternBuilder.java:1593)
at org.drools.compiler.rule.builder.PatternBuilder.buildOperators(PatternBuilder.java:1555)
at org.drools.compiler.rule.builder.PatternBuilder.buildAnalysis(PatternBuilder.java:1527)
at org.drools.compiler.rule.builder.MVELConstraintBuilder.buildCompilationUnit(MVELConstraintBuilder.java:330)
at org.drools.compiler.rule.builder.MVELConstraintBuilder.buildLiteralConstraint(MVELConstraintBuilder.java:198)
at org.drools.compiler.rule.builder.PatternBuilder.buildConstraintForPattern(PatternBuilder.java:1077)
at org.drools.compiler.rule.builder.PatternBuilder.buildRelationalExpression(PatternBuilder.java:1012)
at org.drools.compiler.rule.builder.PatternBuilder.buildExpression(PatternBuilder.java:902)
at org.drools.compiler.rule.builder.PatternBuilder.buildCcdDescr(PatternBuilder.java:878)
at org.drools.compiler.rule.builder.PatternBuilder.build(PatternBuilder.java:725)
at org.drools.compiler.rule.builder.PatternBuilder.processConstraintsAndBinds(PatternBuilder.java:585)
at org.drools.compiler.rule.builder.PatternBuilder.build(PatternBuilder.java:183)
at org.drools.compiler.rule.builder.PatternBuilder.build(PatternBuilder.java:147)
at org.drools.compiler.rule.builder.PatternBuilder.build(PatternBuilder.java:128)
at org.drools.compiler.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:66)
at org.drools.compiler.rule.builder.RuleBuilder.build(RuleBuilder.java:97)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addRule(KnowledgeBuilderImpl.java:1820)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileRules(KnowledgeBuilderImpl.java:1111)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileAllRules(KnowledgeBuilderImpl.java:989)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildRules(CompositeKnowledgeBuilderImpl.java:260)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.java:121)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:105)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.buildKnowledgePackages(AbstractKieModule.java:243)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:64)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:52)
at org.drools.compiler.kie.builder.impl.KieContainerImpl.verify(KieContainerImpl.java:432)
at com.acme.DROOLS_1198.RuleTest.test(RuleTest.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment