[rules-users] Another multi thread error

Mark Proctor mproctor at codehaus.org
Mon Jul 16 15:13:50 EDT 2007


yes someone found that one already, it is fixed in trunk. I'm hoping to 
release a code complete MR4 in a few hours, just waiting on some IDE 
code to be committed.

Mark
Pierre Paysant-Le Roux wrote:
> 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070716/39c44831/attachment.html 


More information about the rules-users mailing list