0
votes

This may be a bit too vague for this forum but I'm trying anyway..

I have Eclipse Juno with the Drools 6.2.0 plugin, using a Java 8 JRE. I have a DRL file which appears to be valid as it runs without error, however Eclipse reports an error: org/drools/StatefulSession.

enter image description here

It also does not pick up syntax errors such as a missing semi-colon, so Eclipse is obviously just not validating correctly.

For example, a very simple rule such as:

rule "ABC"
salience 1000
when
    Person($surname : surname)
then
    logger.info("Surname is " + $surname)
end

does not flag that the logger.info line is missing a semi-colon.

My project that the DRL file is in references the JRE library along with some custom classes.

I have created a Drools runtime via the Eclipse preferences, which is selected.

I noticed that if I select the Drools option "Allow cross reference in DRL files" then the StatefulSession error goes away, but it still won't validate on general Java syntax errors such as missing semi-colons (this might be a more general issue with my Eclipse Java setup).

My drools coding knowledge is adequate but my knowledge of the Eclipse setup and use of Drools plugin isn't I'm afraid so apologies if this is a simple setup issue.

My questions are:

  1. Where is this StatefulSession error coming from and what does it mean?
  2. Why is Eclipse not flagging Java syntax errors in my rules "then" sections?

Thanks in advance.

1
(1) I've never seen an Eclipse error that just says "org/drools/StatefulSession". (2) In DRL, semicolons aren't required in most places, so report the place where you think it is, and not reported, and we'll take it from there. - And what is your question? - laune
I've edited my question, hopefully it's clearer now. - Neil
Drools does not require you to add a semicolon after a statement on the right hand side if there is a line end following it. -- As for the StatefulSession error: is that really all the error message says?? - laune
I've added an image of the error. Sorry it's so small but it shows that it is the only error showing for the rule with the text "org/drools/StatefulSession". - Neil

1 Answers

0
votes

Drools does not require you to add a semicolon after a statement on the right hand side if there is a line end following it.

RHS code is parsed by a special (peculiar) parser, not strictly adhering to Java syntax. It's more lenient, but may not always be able to cope with full Java. Note that it must be able to handle a superset of statements: including modify(...){...} and the "macros" such as insert() or delete().