RuntimeDroolsException does not blaim the correct rule
------------------------------------------------------
Key: JBRULES-2517
URL:
https://jira.jboss.org/browse/JBRULES-2517
Project: Drools
Issue Type: Task
Security Level: Public (Everyone can see)
Components: drools-compiler (expert)
Affects Versions: 5.1.0.M1
Reporter: Geoffrey De Smet
Assignee: Edson Tirelli
Priority: Optional
Fix For: FUTURE
My rules worked fine, until I added this rule
{code}
rule "insertLastEmployeeFreeDaySequence"
salience 1 // Do these rules first (optional, for performance)
when
EmployeeConsecutiveAssignmentEnd(
$employee : employee,
$firstShiftDate : shiftDate,
$firstDayIndex : shiftDateDayIndex
)
// There are no working days between the first and last day
not EmployeeConsecutiveAssignmentStart(
employee == $employee,
shiftDateDayIndex > $firstShiftDate
)
RosterInfo(lastShiftDateDayIndex > $firstDayIndex, $lastShiftDate :
lastShiftDate)
then
insertLogical(new EmployeeFreeDaySequence($employee, $firstShiftDate,
$lastShiftDate));
end
{code}
However, the output I got, blamed another rule, namely
"insertEmployeeConsecutiveAssignmentEnd", one that worked perfectly:
{code}
Exception in thread "main" org.drools.runtime.rule.ConsequenceException: rule:
insertEmployeeConsecutiveAssignmentEnd
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:738)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:704)
at
org.drools.planner.core.localsearch.LocalSearchSolverScope.calculateScoreFromWorkingMemory(LocalSearchSolverScope.java:145)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solvingStarted(DefaultLocalSearchSolver.java:165)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solveImplementation(DefaultLocalSearchSolver.java:105)
at org.drools.planner.core.AbstractSolver.solve(AbstractSolver.java:41)
at
org.drools.planner.benchmark.SolverBenchmarkSuite.benchmark(SolverBenchmarkSuite.java:196)
at
org.drools.planner.benchmark.XmlSolverBenchmarker.benchmark(XmlSolverBenchmarker.java:72)
at
org.drools.planner.examples.common.app.CommonBenchmarkApp.process(CommonBenchmarkApp.java:25)
at
org.drools.planner.examples.nurserostering.app.NurseRosteringBenchmarkApp.main(NurseRosteringBenchmarkApp.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
Caused by: org.drools.RuntimeDroolsException: Conversion to long not supported from
org.drools.planner.examples.nurserostering.domain.ShiftDate
at
org.drools.base.extractors.BaseObjectClassFieldReader.getLongValue(BaseObjectClassFieldReader.java:136)
at org.drools.base.ClassFieldReader.getLongValue(ClassFieldReader.java:171)
at
org.drools.rule.VariableRestriction$LongVariableContextEntry.updateFromTuple(VariableRestriction.java:445)
at
org.drools.common.DoubleBetaConstraints.updateFromTuple(DoubleBetaConstraints.java:135)
at org.drools.reteoo.NotNode.assertLeftTuple(NotNode.java:76)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:204)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:91)
at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:148)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:434)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:362)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:189)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1127)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1076)
at org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:162)
at org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:133)
at
org.drools.planner.examples.nurserostering.solver.Rule_insertEmployeeConsecutiveAssignmentEnd_0.defaultConsequence(Rule_insertEmployeeConsecutiveAssignmentEnd_0.java:14)
at
org.drools.planner.examples.nurserostering.solver.Rule_insertEmployeeConsecutiveAssignmentEnd_0DefaultConsequenceInvoker.evaluate(Rule_insertEmployeeConsecutiveAssignmentEnd_0DefaultConsequenceInvoker.java:34)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
... 17 more
{code}
It wasn't "insertEmployeeConsecutiveAssignmentEnd" which had an error, but
it was (of course) the rule "insertLastEmployeeFreeDaySequence" I just added and
it has this bug:
{code}
not EmployeeConsecutiveAssignmentStart(...
shiftDateDayIndex > $firstShiftDate
)
{code}
should be
{code}
not EmployeeConsecutiveAssignmentStart(...
shiftDateDayIndex > $firstDayIndex
)
{code}
The compiler should blame the rule "insertLastEmployeeFreeDaySequence" instead
of the rule "insertEmployeeConsecutiveAssignmentEnd".
Reproduce recipe: simply change it back to the wrong code in:
drools/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira