-
Bug
-
Resolution: Done
-
Major
-
6.0.0.Final, 6.0.1.Final
-
None
-
None
If I reuse a KieSession for multiple times, it seems to forget about the function defined in the DRL file.
DRL:
package org.drools.example.api.defaultkiesession.Hal1 import org.drools.example.api.defaultkiesession.Message function boolean alwaysTrue() { return true; } rule "rule 1" when m : Message( ) then retract(m); end rule "rule 2" when Message( alwaysTrue(), text == "Hello, HAL. Do you read me, HAL?" ) then insert( new Message("HAL", "Dave. I read you." ) ); end
Java code:
package org.drools.example.api.defaultkiesession; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; public class DefaultKieSessionExample { static int counter = 0; public void failCase1() { KieServices ks = KieServices.Factory.get(); KieContainer kContainer = ks.getKieClasspathContainer(); KieSession kSession = kContainer.newKieSession(); for( counter = 0; counter < 10000; ++counter) { kSession.insert(new Message("Dave", "Hello, HAL. Do you read me, HAL?")); kSession.fireAllRules(); if (kSession.getFactCount() != 0) { System.err.println("error"); } } } public static void main(String[] args) { try { DefaultKieSessionExample defaultKieSessionExample = new DefaultKieSessionExample(); defaultKieSessionExample.failCase1(); } catch (NoClassDefFoundError error) { System.err.println("Failed after "+counter+" testcases"); error.printStackTrace(); } } }
Runs fine for some iterations, and after a while an exception happens:
java.lang.NoClassDefFoundError: org/drools/example/api/defaultkiesession/Hal1/AlwaysTrue at ConditionEvaluator19fe4e382c304060b0046f5cdc6a59fa.evaluate(Unknown Source) at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:217) at org.drools.core.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:174) at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:134) at org.drools.core.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:502) at org.drools.core.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:387) at org.drools.core.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:288) at org.drools.core.reteoo.EntryPointNode.assertObject(EntryPointNode.java:260) at org.drools.core.common.NamedEntryPoint.insert(NamedEntryPoint.java:360) at org.drools.core.common.NamedEntryPoint.insert(NamedEntryPoint.java:279) at org.drools.core.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1148) at org.drools.core.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1092) at org.drools.core.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:308) at org.drools.example.api.defaultkiesession.DefaultKieSessionExample.failCase1(DefaultKieSessionExample.java:17) at org.drools.example.api.defaultkiesession.DefaultKieSessionExample.main(DefaultKieSessionExample.java:29) Caused by: java.lang.ClassNotFoundException: org.drools.example.api.defaultkiesession.Hal1.AlwaysTrue at org.drools.core.common.ProjectClassLoader.tryDefineType(ProjectClassLoader.java:123) at org.drools.core.common.ProjectClassLoader.loadType(ProjectClassLoader.java:114) at org.drools.core.common.ProjectClassLoader.loadClass(ProjectClassLoader.java:84) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 15 more