Hi, I solved my first multi thread problem by having a shared RuleBase for all threads. My problem is now with Objects insertion. Here is the trace that occur : java.lang.ArrayIndexOutOfBoundsException: 17 at org.drools.util.AbstractHashTable$HashTableIterator.next(AbstractHashTable.java:250) at org.drools.reteoo.Rete$ObjectTypeConf.buildCache(Rete.java:434) at org.drools.reteoo.Rete$ObjectTypeConf.getObjectTypeNodes(Rete.java:425) at org.drools.reteoo.Rete.assertObject(Rete.java:172) 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 test.TestThreads$DroolsThread.run(TestThreads.java:65) at java.lang.Thread.run(Thread.java:534) The program that I made to reproduce this error create threads that each create a working memory from a static rule base (that works great) and then insert some objects in this working memory. I have this error in a real j2ee program. Here is a listing of the code : package test; import java.io.IOException; import java.io.InputStreamReader; import org.drools.RuleBase; import org.drools.RuleBaseFactory; import org.drools.StatefulSession; import org.drools.compiler.DroolsParserException; import org.drools.compiler.PackageBuilder; import org.drools.compiler.PackageBuilderConfiguration; public class TestThreads { public static RuleBase rulebase; public static void main(String[] args) { PackageBuilderConfiguration pkgBuilderCfg = new PackageBuilderConfiguration(); PackageBuilder builder = new PackageBuilder(pkgBuilderCfg); try { builder.addPackageFromDrl(new InputStreamReader( TestThreads.class.getResourceAsStream( "Sample.drl" ))); } catch (DroolsParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } rulebase = RuleBaseFactory.newRuleBase(); try { rulebase.addPackage(builder.getPackage()); } catch (Exception e) { e.printStackTrace(); } for(int i = 0; i<100 ; i++) { DroolsThread tt = new DroolsThread("Thread " + i); new Thread(tt).start(); } } public static class Fact { public String s; public Fact(String s){ this.s = s; } public String getS() { return s; } } public static class DroolsThread implements Runnable { private String id; public DroolsThread(String id) { this.id = id; } public void run() { StatefulSession session = rulebase.newStatefulSession(); for(int i = 0; i < 100; i++) { session.insert(new Fact(id)); } } } } I am using Drools MR3. Thanks for your help. Pierre Paysant-Le Roux
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users