[jboss-jira] [JBoss JIRA] (DROOLS-839) Accumulate Function ClassCastException
Eugene Shvartsman (JIRA)
issues at jboss.org
Sun Jul 12 22:16:02 EDT 2015
[ https://issues.jboss.org/browse/DROOLS-839?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eugene Shvartsman updated DROOLS-839:
-------------------------------------
Steps to Reproduce:
Extract the two Maven modules in the zip file and import into Eclipse.
One module will contain the domain model and the other the JUnit test code that causes the error.
Run the MaxHoursPerDayTester class in order to see the error.
was:
Execute rules on a data set that would cause the firing of above rule.
A reproduce can be extracted if required, just let me know and I'll ask for some time to work on it.
> Accumulate Function ClassCastException
> --------------------------------------
>
> Key: DROOLS-839
> URL: https://issues.jboss.org/browse/DROOLS-839
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 6.2.0.CR4, 6.3.0.Beta1
> Environment: Mac OS X 10.10.3
> Reporter: Eugene Shvartsman
> Assignee: Mario Fusco
> Attachments: Drools-839-Reproducer.zip
>
>
> I am getting a ClassCastException with the following LHS side of the rule. The sample I am posting is the simplest version of the rule that I could create while still retaining the error.
> {code:title=Rule.drl|borderStyle=solid}
> rule "reproducer"
> dialect "mvel"
> enabled true
> when
> $contract : Contract( $contractRefId : contractRefId, $scope : scope )
> (or
> $employee : Employee ($scope == ContractScope.EmployeeContract && employeeId == $contractRefId)
> $employee : Employee ($scope == ContractScope.TeamContract)
> )
> $contractLine : MinMaxContractLine( contractLineType == ContractLineType.HOURS_PER_DAY, $maxMinutesValue : maximumValue, $weight : maximumWeight,
> maximumEnabled == true, $contract == contract)
> $info : EmployeeRosterInfo( $type : profileDayType, $firstDayOfWeek : firstDayOfWeek )
> $shiftDate : ShiftDate(isInPlanningWindow($info))
> accumulate ( $shift : ShiftAssignment( employee != null, employee == $employee
> ,getDateByProfileDayType($type).equals($shiftDate)
> ,$minutes : shiftDurationMinutes)
> ,$minutesInDay : sum( $shift.getShiftDurationMinutesByProfileType($type, $shiftDate) )
> ,$shiftsInvolved : collectList($shift)
> )
> then
> end
> {code}
> During the execution of the rules I get the following stack trace:
> {code:title=StackTrace.java|borderStyle=solid}
> java.lang.RuntimeException: java.lang.ClassCastException: com.x.engine.domain.ShiftDate cannot be cast to com.x.engine.domain.dto.ProfileDayType
> at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:90)
> at org.drools.core.phreak.PhreakAccumulateNode.addMatch(PhreakAccumulateNode.java:759)
> at org.drools.core.phreak.PhreakAccumulateNode.doLeftInserts(PhreakAccumulateNode.java:163)
> at org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:80)
> at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:569)
> at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:540)
> at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:336)
> at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:163)
> at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:118)
> at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:194)
> at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:62)
> at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:974)
> at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1283)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1325)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1308)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1287)
> at com.x.engine.drools.hardconstraints.MaxHoursPerDayTester.testMaxHoursTwoShiftsViolatedStartDateType(MaxHoursPerDayTester.java:244)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
> at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
> Caused by: java.lang.ClassCastException: com.x.engine.domain.ShiftDate cannot be cast to com.x.engine.domain.dto.ProfileDayType
> at com.x.engine.solver.rules.constraints.Rule_maxHoursPerDay1799802206AccumulateExpression0Invoker.evaluate(Rule_maxHoursPerDay1799802206AccumulateExpression0Invoker.java:17)
> at org.drools.core.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(JavaAccumulatorFunctionExecutor.java:109)
> at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:82)
> ... 41 more
> {code}
> If I replace $shift.getShiftDurationMinutesByProfileType($type, $shiftDate) with $shift.getShiftDurationMinutesByProfileType($type, $shift.getShiftDate()) the issue goes away for some reason. Sadly this does not work as a workaround in my real case.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
More information about the jboss-jira
mailing list