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

Fact metadata declared in a POJO are lost when declaring fact metadata in DRL

    XMLWordPrintable

    Details

      Description

      Assume a POJO is used as a fact and annotated with @Position as follows:

      public class PositionAnnotatedEvent {

      @Position(1)
      private String arg1;

      @Position(0)
      private String arg0;

      // getters and setters
      }

      When I add some metadata to this class in DRL, for example:

      declare org.jboss.qa.brms.bre.regression.POJOAnnotationMergeTest.PositionAnnotatedEvent
      @role(event)
      end

      Then the following rule using positional arguments does not compile, producing an IndexOutOfBoundsException with message 'Error trying to access field at position 0'. The same rule with named arguments compiles:

      rule 'sample rule'
      when
      org.jboss.qa.brms.bre.regression.POJOAnnotationMergeTest.PositionAnnotatedEvent( 'value1', 'value2'; )
      then
      end

      The relevant stack trace follows:

      java.lang.IndexOutOfBoundsException: Error trying to access field at position 0
      at org.drools.factmodel.ClassDefinition.getField(ClassDefinition.java:162)
      at org.drools.rule.builder.PatternBuilder.processPositional(PatternBuilder.java:432)
      at org.drools.rule.builder.PatternBuilder.processConstraintsAndBinds(PatternBuilder.java:392)
      at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:310)
      at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:131)
      at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:65)
      at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:80)
      at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2578)
      at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:970)
      at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:456)
      at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:643)
      at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:41)

        Attachments

          Activity

            People

            Assignee:
            mfusco Mario Fusco
            Reporter:
            mfusco Mario Fusco
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: