Search code examples
javaeclipseeclipse-plugindrools

Eclipse Drools 6.2.0 Plugin Error: org/drools/StatefulSession


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.


Solution

  • 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().