Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-1180

java.lang.ClassCastException: org.drools.reteoo.RightInputAdapterNode

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.0.1
    • Fix Version/s: 4.0.2
    • Component/s: None
    • Labels:
      None
    • Environment:

      JDK 1.5, Mac OS X 10.4

      Description

      Using the rules

      package test

      import java.awt.*;

      rule "A"

      when
      exists(x : Dimension(x_height : height) and
      y : Dimension(this!=x, height!=x_height))

      then
      System.out.println("A");
      end

      rule "B"

      when
      not(exists(x : Dimension(x_height : height) and
      y : Dimension(this!=x, height!=x_height)))

      then
      System.out.println("B");
      end

      as input for the following program (java DroolsTest <name of rule file>)

      import org.drools.*;
      import org.drools.compiler.*;
      import org.drools.rule.Package;

      import java.io.*;
      import java.awt.*;

      public class DroolsTest {
      private RuleBase rules;
      private StatefulSession memory;

      public DroolsTest(File file) throws Exception

      { rules =RuleBaseFactory.newRuleBase(); memory=rules.newStatefulSession(); rules.addPackage(loadPackage(file)); }

      protected Package loadPackage(File file) throws IOException {
      FileInputStream stream=null;

      try

      { stream=new FileInputStream(file); return(loadPackage(stream)); }

      finally

      { if (stream!=null) stream.close(); }

      }

      protected Package loadPackage(InputStream stream) throws IOException {
      try

      { PackageBuilder builder=new PackageBuilder(); builder.addPackageFromDrl(new InputStreamReader(stream)); return(builder.getPackage()); }

      catch(Exception ex)

      { throw new IOException(); }

      }

      public StatefulSession getSession()

      { return(memory); }

      public static void main(String ... args) {
      try

      { DroolsTest test=new DroolsTest(new File(args[0])); System.out.println("Inserting ..."); test.getSession().insert(new Dimension(1,2)); test.getSession().insert(new Dimension(2,3)); test.getSession().insert(new Dimension(4,2)); System.out.println("Done."); System.out.println("Firing rules ..."); test.getSession().fireAllRules(); System.out.println("Done."); }

      catch (Exception ex)

      { ex.printStackTrace(); }

      }
      }

      leads to

      java.lang.ClassCastException: org.drools.reteoo.RightInputAdapterNode
      at org.drools.reteoo.CompositeTupleSinkAdapter.addTupleSink(CompositeTupleSinkAdapter.java:17)
      at org.drools.reteoo.TupleSource.addTupleSink(TupleSource.java:79)
      at org.drools.reteoo.RightInputAdapterNode.attach(RightInputAdapterNode.java:127)
      at org.drools.reteoo.RightInputAdapterNode.attach(RightInputAdapterNode.java:131)
      at org.drools.reteoo.builder.BuildUtils.attachNode(BuildUtils.java:132)
      at org.drools.reteoo.builder.GroupElementBuilder$ExistsBuilder.build(GroupElementBuilder.java:290)
      at org.drools.reteoo.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
      at org.drools.reteoo.builder.GroupElementBuilder$NotBuilder.build(GroupElementBuilder.java:207)
      at org.drools.reteoo.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
      at org.drools.reteoo.builder.GroupElementBuilder$AndBuilder.build(GroupElementBuilder.java:111)
      at org.drools.reteoo.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
      at org.drools.reteoo.builder.ReteooRuleBuilder.addSubRule(ReteooRuleBuilder.java:136)
      at org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:109)
      at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:116)
      at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:268)
      at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:337)
      at DroolsTest.<init>(Unknown Source)
      at DroolsTest.main(Unknown Source)

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tirelli Edson Tirelli
                Reporter:
                marreitz Markus Reitz
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: