Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-3734

Executable model: Imports not evaluated correctly for fact declarations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • None
    • 7.12.0.Final, 7.17.0.Final
    • None
    • None
    • Hide

      In a simple project with a Java defined fact class and a rules.drl file, have a type declaration in rules.drl extend the java defined fact class. Build with

      mvn clean install -DgenerateModel=YES

      and observe error similar to the following:

      [ERROR] Unable to build KieBaseModel:all
      CompilationProblemErrorResult: cannot find symbol
        symbol:   class MyFact
        location: package olijohns
      CompilationProblemErrorResult: cannot find symbol
        symbol: class MyFact
      

      Project structure is:
      src/main/java/olijohns/MyFact.java
      src/main/resources/META-INF/kmodule.xml
      src/main/resources/olijohns/rules.drl
      pom.xml

      contents of rules.drl:

      package olijohns
      
      import olijohns.MyFact // Not strictly needed, below usage causes errors either way
      
      declare FactA extends MyFact
      end
      

      contents of MyFact.java:

      package olijohns;
      
      public class MyFact {
      }
      
      Show
      In a simple project with a Java defined fact class and a rules.drl file, have a type declaration in rules.drl extend the java defined fact class. Build with mvn clean install -DgenerateModel=YES and observe error similar to the following: [ERROR] Unable to build KieBaseModel:all CompilationProblemErrorResult: cannot find symbol symbol: class MyFact location: package olijohns CompilationProblemErrorResult: cannot find symbol symbol: class MyFact Project structure is: src/main/java/olijohns/MyFact.java src/main/resources/META-INF/kmodule.xml src/main/resources/olijohns/rules.drl pom.xml contents of rules.drl: package olijohns import olijohns.MyFact // Not strictly needed, below usage causes errors either way declare FactA extends MyFact end contents of MyFact.java: package olijohns; public class MyFact { }
    • NEW
    • NEW

      If using the executable model (building with -DgenerateModel=YES) compilation errors occur for types defined in Java being used in DRL of the same maven model.

      When attempting to import a Java class defined under the same pom.xml module as the current rules file 'CompilationProblemErrorResult: cannot find symbol' errors are observed. Even when the import is not needed (Java type defined in same package as DRL rules), if the type is used in a type declaration the 'cannot find symbol' error is still observed.

      Errors are of the form:

      [ERROR] Unable to build KieBaseModel:all
      CompilationProblemErrorResult: cannot find symbol
        symbol:   class MyFact
        location: package olijohns
      CompilationProblemErrorResult: cannot find symbol
        symbol: class MyFact
      

              mfusco@redhat.com Mario Fusco
              olijohns-cisco Olli Johnson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: