can you make an integration test for us? As we'll need to be easily able
to reproduce this. We'll add it to our code base and fix. We'll probably
add it as aprt of the MiscTest class:
I am trying to sequentially perform two rules executions using two
different classloaders in the same VM. I create completely new state
for each execution, yet I still fail on the second execution. I
believe this has to do with some internal static cached state that
JBossRules is maintaining. A snippet of the code and exeception are
shown in this email.
public void demo() throws Exception {
// Save original classloader
ClassLoader original =
Thread.currentThread().getContextClassLoader();
// Create Classloader 1 with parent of original
FooClassLoader loader1 = new FooClassLoader(original);
Thread.currentThread().setContextClassLoader(loader1);
testRules();
// Success so far...
// Create Classloader 2 with parent of original
FooClassLoader loader2 = new FooClassLoader(original);
Thread.currentThread().setContextClassLoader(loader2);
testRules();
// Never make it to here.
// Restore
Thread.currentThread().setContextClassLoader(original);
}
private void testRules() throws Exception {
PackageBuilder builder = new PackageBuilder();
Package pkg = buildPackage(new String[] { "Foo.drl" }, builder);
RuleBase base = RuleBaseFactory.newRuleBase();
base.addPackage(pkg);
StatelessSession session = base.newStatelessSession();
final ClassLoader loader =
Thread.currentThread().getContextClassLoader();
Object inst = loader.loadClass("com.foo.Foo").newInstance();
session.execute(new Object[] { inst });
}
Exception in thread "main" java.lang.ClassCastException:
adixon.prototype.rules.classloader.demo.copy.FooShadowProxy
at
org.drools.base.adixon.prototype.rules.classloader.demo.copy.Foo$getName.getValue(Unknown
Source)
at
org.drools.base.ClassFieldExtractor.getValue(ClassFieldExtractor.java:94)
at
org.drools.base.evaluators.StringFactory$StringEqualEvaluator.evaluate(StringFactory.java:85)
at
org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:61)
at
org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:82)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:121)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:20)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:159)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:70)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:772)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:584)
at
org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:63)
at
adixon.prototype.rules.classloader.demo.copy.Driver.testRules(Driver.java:47)
at
adixon.prototype.rules.classloader.demo.copy.Driver.go(Driver.java:33)
at
adixon.prototype.rules.classloader.demo.copy.Driver.main(Driver.java:17)
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev