Error in drools rule syntax
iiitarajesh Apr 29, 2019 8:15 AMI am trying to create rules from the database so creating a list which have rulename,lhs and rhs. Also I am trying to create rules using two pojo object but some how i am getting exception in rule syntax. Below is the code snippet.
for (int i = 0; i < 5; i++) {
dbRules = new DbRules(i, "Rule Name - " + i, " $mdmContractHeader : MdmContractHeader( $s : supplierName ) $contractHeader1 : ContractHeader ( supplierName == $s ) "
+ " && contractHeader:ContractHeader(supplierId >= 100)",
"System.out.print(\"Test, Drools rule - " + i
+ ".! \"); System.out.println(contractHeader.getSupplierName());");
list.add(dbRules);
}
and Below is the error in console.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.RuntimeException: Unable to get KieModule, Errors Existed: Error Messages:
Message [id=1, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:324 mismatched input '$contractHeader1' in rule "Rule Name - 0"]
Message [id=2, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:733 mismatched input '$contractHeader1' in rule "Rule Name - 1"]
Message [id=3, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:1142 mismatched input '$contractHeader1' in rule "Rule Name - 2"]
Message [id=4, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:1551 mismatched input '$contractHeader1' in rule "Rule Name - 3"]
Message [id=5, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:1960 mismatched input '$contractHeader1' in rule "Rule Name - 4"]
Message [id=6, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=0, column=0
text=Parser returned a null Package]
---
Warning Messages:
---
Info Messages:
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:467)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:453)
at com.sample.StringDroolsMdm.executeRules(StringDroolsMdm.java:118)
at com.sample.StringDroolsMdm.main(StringDroolsMdm.java:70)