Skip to main content
Aletyx Enterprise Build of Drools provides standardized messages for DRL errors to help you troubleshoot and resolve problems in your DRL files. The error messages provided with some of the examples included in this section are designed to help you locate and resolve your issue. There are four main types of error codes that will be found within this section and multiple may apply in a single file at any given time.

The Error Codes

Drools Parsing Errors: Understanding Common Issues

When working with Drools, parsing errors can be tricky. Below is a table of common errors, what they mean, and how to resolve them.

DRL Error Structure Visualization Methods

Let’s breakdown the structure of a Drools Rules Language (DRL) error as understanding how they are presented so that we can solve the problem. Let’s first look at this line in a log from a rule we wrote
  • 1st Block: Error code
  • 2nd Block: Line and column in the DRL source where the error occurred
  • 3rd Block: Description of the problem
  • 4th Block: Component in the DRL source (rule, function, query) where the error occurred
  • 5th Block: Pattern in the DRL source where the error occurred (if applicable)

Spelling Issue - No Viable Alternative

Example rule with incorrect spelling.
  1. Exists is spelt wrong and is exits so the rule talks Must be exists.
Error message.

Rule without a Name

Example rule without a rule name.
  1. Must be rule "rule name" (or rule rule_name if no spacing). There is a requirement of a rule name to be present.
Error message.
In this example, the parser encountered the keyword when but expected the rule name, so it flags when as the incorrect expected token.

Incorrect Syntax Usage

Example rule with incorrect syntax
  1. This is missing a closing quotation on the Andy parameter.
  1. This is missing a closing quotation on the Andy parameter.
Error message.
A line and column value of 0:-1 means the parser reached the end of the source file (<eof>) but encountered incomplete constructs, usually due to missing quotation marks "…​", apostrophes '…​', or parentheses (…​). 102: mismatched input Indicates that the parser expected a particular symbol that is missing at the current input position.

Incomplete Rule Statement

Example rule with an incomplete rule statement.
Error message.
A line and column value of 0:-1 means the parser reached the end of the source file (<eof>) but encountered incomplete constructs, usually due to missing quotation marks "…​", apostrophes '…​', or parentheses (…​). Example rule with incorrect syntax.
  1. Must use && operators instead of commas ,
Error messages.
In this example, the syntactic problem results in multiple error messages related to each other. The single solution of replacing the commas , with && operators resolves all errors. If you encounter multiple errors, resolve one at a time in case errors are consequences of previous errors. 103: failed predicate Indicates that a validating semantic predicate evaluated to false. These semantic predicates are typically used to identify component keywords in DRL files, such as declare, rule, exists, not, and others.

Invalid Keyword

Example rule with an invalid keyword.
  1. Must be a valid DRL keyword
Error message.
The Some text line is invalid because it does not begin with or is not a part of a DRL keyword construct, so the parser fails to validate the rest of the DRL file. This error is similar to 102: mismatched input, but usually involves DRL keywords. 105: did not match anything Indicates that the parser reached a sub-rule in the grammar that must match an alternative at least once, but the sub-rule did not match anything. The parser has entered a branch with no way out.