History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: DROOLS-470
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Michael Neale
Reporter: Kris Verlaenen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
drools-legacy

condition ending with ; is not considered as wrong when parsing ruleset but generates error when asserting an object

Created: 04/Jan/06 08:22 AM   Updated: 15/Jan/06 07:51 PM
Component/s: semantics.java
Affects Version/s: 2.5
Fix Version/s: 2.5

Time Tracking:
Not Specified


 Description  « Hide
When creating a java condition ending with a semi-colon, loading of the ruleset is successful.
e.g. when creating a rule containing
<java:condition>
true;
</java:condition>
then
ruleBase = RuleBaseLoader.loadFromInputStream(this.getClass().getResourceAsStream( "/myrule.java.drl" ))
does not generate any errors.

Although, when asserting an object in the working memory that leads to the evaluation of that condition, first some output is written to the system out, followed by an exception:

drools/org/MyRuleSet_1136384249796/java/Allow_ProviderA_access_0.java(26)
Syntax error on token ";", delete this token
drools/org/MyRuleSet_1136384249796/java/Allow_ProviderA_access_0.java(26)
Syntax error on token ";", delete this token

java.lang.NoClassDefFoundError: drools/org/MyRuleSet_1136384249796/java/Allow_ProviderA_access_0
at drools.org.MyRuleSet_1136384249796.java.Allow_ProviderA_access_0Invoker$Condition_1Invoker.invoke(Allow_ProviderA_access_0Invoker.java:36)
at org.drools.semantics.java.JavaCondition.isAllowed(JavaCondition.java:172)
at org.drools.reteoo.ConditionNode.assertTuple(ConditionNode.java:154)
at org.drools.reteoo.TupleSource.propagateAssertTuple(TupleSource.java:118)
at org.drools.reteoo.ParameterNode.assertObject(ParameterNode.java:126)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:173)
at org.drools.reteoo.Rete.assertObject(Rete.java:111)
at org.drools.reteoo.RuleBaseImpl.assertObject(RuleBaseImpl.java:193)
at org.drools.reteoo.WorkingMemoryImpl.assertObject(WorkingMemoryImpl.java:373)
at org.drools.reteoo.WorkingMemoryImpl.assertObject(WorkingMemoryImpl.java:348)

If a ; is not allowed in a condition, this problem should be detected when parsing the ruleset.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Kris Verlaenen - 09/Jan/06 09:19 AM
The problem seems to be much more general:
When parsing java rules, java errors are not detected in conditions and actions in a lot of cases and generate errors at runtime.
Examples include referencing undeclared parameters, using methods or classes that are unknown, invalid use of methods (wrong args etc), and many more.

Michael Neale - 15/Jan/06 07:51 PM
Kris, this should be much better in beta 2, or CVS HEAD.

Problem was JCI CompilerProblem[] was being printed out and ignored. This now throws exceptions before it gets to runtime. Should report more useful information.

There is a new exception class in drools-java: JavaSemanticCompileError

getErrors() will return a list of compile problems. Otherwise printing it out will show a human readable summary of what is wrong.