[rules-users] ClassCastException after migrating from Drools 4.x to v5.5

Wolfgang Laun wolfgang.laun at gmail.com
Mon Feb 18 04:07:50 EST 2013


Mark,

On 18/02/2013, Mark Proctor <mproctor at codehaus.org> wrote:
> stateless is just a wrapped stateful session - insert, update and delete
> work as normal.

So let's get this straight, this quote from the "Expert" manual which
does NOT refer to sequential mode!!) is wrong and should be removed:
<quote>
Stateless sessions do not support iterative insertions and the method
call fireAllRules() from Java code;
</quote>

>
> For "sequential" mode, inserts will reach the right input of a beta node and
> then just do nothing - as all the beta network evaluation has been done.

Which I take it to mean that you can do insert (and retract? and
modify?) but it will not work as intended? Without error indication??

-W

>
> Mark
> On 18 Feb 2013, at 07:17, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:
>
>> I may be mistaken, but the stack trace looks as if a stateless
>> knowledge session is being run, wherein it executes a RHS
>> ("employeePreloadSystemConstants") where some fact is being inserted.
>>
>> Not sure what *ought* to happen in this case, though: I've been trying
>> to find this out ever since 5.1.x. A meagre "...do not support
>> iterative insertions..." is all there is to be read, but what does
>> this imply? Simply doesn't work in an unspecified way? May crash on
>> workdays...?? A "tut, tut" from the Drools Team ??? ;-)
>>
>> -W
>>
>>
>> On 18/02/2013, Mark Proctor <mproctor at codehaus.org> wrote:
>>> Looks like an 'or' bug. Which is surprising, as we had 'or' bugs in 4.x,
>>> and
>>> fixed a lot of them for 5.x.
>>>
>>> Could you build and try 5.5.x here now, this is the branch for the 5.6
>>> release:
>>> https://github.com/droolsjbpm/drools/tree/5.5.x
>>>
>>> If it's still not fixed, could you write an isolated test? Seems like
>>> you
>>> only need one rule, and two or three facts to trigger it. Ideally please
>>> re-use facts from the test classes already existing - details of how to
>>> write tests, and submit as pull requests is here:
>>> http://docs.jboss.org/drools/release/5.4.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html
>>>
>>> If you can get us this test pull request asap (next few days), we'll fix
>>> and
>>> get it into the 5.6 release. Otherwise you may have to wait some time for
>>> a
>>> fix.
>>>
>>> Mark
>>> On 18 Feb 2013, at 01:10, ismaximum <mnrz57 at gmail.com> wrote:
>>>
>>>> Ah sorry.. It seems my first message hasn't been accepted by the
>>>> user-list...
>>>> I post it again here:
>>>>
>>>> After we upgrade to Drools v 5.5 there are hundreds of errors in test
>>>> cases
>>>> related to our rules.
>>>> One of which is related to this ClassCastException which I noticed it
>>>> occurs
>>>> when we have nested OR statements
>>>>
>>>> Here is one example:
>>>>
>>>> rule "employeeContributionStartDateAfterAccountStartDate"
>>>>   ruleflow-group "EmployeeValidation"
>>>>   when
>>>>               // We only want this rule to fire when we are using the
>>>> create:Employee node.  NOTE that the startDate or contributionStartDate
>>>> cannot be updated
>>>>               EmployeeDetailsRulesModel(create == true)
>>>>               // Get the date to validate
>>>>       Employee( $contributionStartDate : contributionStartDate != null
>>>> )
>>>>       (or
>>>>           (and
>>>>               // i.e. The contribution start date and the account start
>>>> dates are both specified.
>>>>               Account( $accountStartDate : accountStartDate != null )
>>>>               eval( $contributionStartDate.compare($accountStartDate) <
>>>> 0
>>>> )
>>>>           )
>>>>           (and
>>>>               // The contribution start date is specified but the
>>>> account
>>>> start date is not, but should be defaulted to today.
>>>>               Account( accountId == null, accountStartDate == null )
>>>>               SystemConstants($today : currentSystemDateWithoutTime)
>>>>               eval(
>>>> $contributionStartDate.compare(jaxbUtils.toXMLGregorianCalendarDateOnly($today))
>>>> < 0 )
>>>>           )
>>>>           (and
>>>>               // for an existing account where the account start date
>>>> is
>>>> not specified.
>>>>               Account( $accountId : accountId != null,
>>>> $accountStartDate
>>>> :
>>>> accountStartDate == null )
>>>>               $composerMemberAccount : BaseMemberAccount() from
>>>> memberAccountDAO.getMemberAccount($accountId)
>>>>               eval(
>>>> $contributionStartDate.compare(jaxbUtils.toXMLGregorianCalendarDateOnly($composerMemberAccount.getFundStartDate()))
>>>> < 0 )
>>>>           )
>>>>       )
>>>>   then
>>>>       error(ApplicationArea.EMPLOYEE, kcontext);
>>>> end
>>>>
>>>>
>>>>
>>>> Here is the error message:
>>>>
>>>> Exception executing consequence for rule
>>>> "employeePreloadSystemConstants"
>>>> in
>>>> com.cname.rules.validation.business: org.drools.RuntimeDroolsException:
>>>> com.cname.rules.validation.business.Rule_employeeContributionStartDateAfterAccountStartDate_357b04c70dac4f469ea9cedd93d15da7Eval1Invoker at d3924bbc
>>>> : java.lang.ClassCastException:
>>>> com.cname.rules.model.common.EmployeeDetailsRulesModel cannot be cast
>>>> to
>>>> com.cname.cbis.domain.update.Account
>>>>       at
>>>> org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
>>>>       at
>>>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
>>>>       at
>>>> org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
>>>>       at
>>>> org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
>>>>       at
>>>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
>>>>       at
>>>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
>>>>       at
>>>> org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
>>>>       at
>>>> org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:106)
>>>>       at
>>>> org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:32)
>>>>       at
>>>> org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
>>>>       at
>>>> org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
>>>>       at
>>>> org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:264)
>>>>       at
>>>> com.cname.rules.CBISAbstractRuleCoverageTest.runValidation(CBISAbstractRuleCoverageTest.java:441)
>>>>       at
>>>> com.cname.rules.business.EmployeeBusinessRulesTest.testEmployeeContributionStartDateAfterAccountStartDate(EmployeeBusinessRulesTest.java:348)
>>>>       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 junit.framework.TestCase.runTest(TestCase.java:168)
>>>>       at junit.framework.TestCase.runBare(TestCase.java:134)
>>>>       at junit.framework.TestResult$1.protect(TestResult.java:110)
>>>>       at junit.framework.TestResult.runProtected(TestResult.java:128)
>>>>       at junit.framework.TestResult.run(TestResult.java:113)
>>>>       at junit.framework.TestCase.run(TestCase.java:124)
>>>>       at junit.framework.TestSuite.runTest(TestSuite.java:243)
>>>>       at junit.framework.TestSuite.run(TestSuite.java:238)
>>>>       at
>>>> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
>>>>       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:467)
>>>>       at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>>>       at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>>>       at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>>>> Caused by: org.drools.RuntimeDroolsException:
>>>> com.cname.rules.validation.business.Rule_employeeContributionStartDateAfterAccountStartDate_357b04c70dac4f469ea9cedd93d15da7Eval1Invoker at d3924bbc
>>>> : java.lang.ClassCastException:
>>>> com.cname.rules.model.common.EmployeeDetailsRulesModel cannot be cast
>>>> to
>>>> com.cname.cbis.domain.update.Account
>>>>       at
>>>> org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:119)
>>>>       at
>>>> org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:176)
>>>>       at
>>>> org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
>>>>       at
>>>> org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:71)
>>>>       at
>>>> org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:159)
>>>>       at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
>>>>       at
>>>> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
>>>>       at
>>>> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
>>>>       at
>>>> org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
>>>>       at
>>>> org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
>>>>       at
>>>> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
>>>>       at
>>>> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
>>>>       at
>>>> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
>>>>       at
>>>> org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:192)
>>>>       at
>>>> org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:186)
>>>>       at
>>>> com.cname.rules.validation.business.Rule_employeePreloadSystemConstants_dcf7facf199041d3aa8f3b85387b4318.defaultConsequence(Rule_employeePreloadSystemConstants_dcf7facf199041d3aa8f3b85387b4318.java:7)
>>>>       at
>>>> com.cname.rules.validation.business.Rule_employeePreloadSystemConstants_dcf7facf199041d3aa8f3b85387b4318DefaultConsequenceInvokerGenerated.evaluate(Unknown
>>>> Source)
>>>>       at
>>>> com.cname.rules.validation.business.Rule_employeePreloadSystemConstants_dcf7facf199041d3aa8f3b85387b4318DefaultConsequenceInvoker.evaluate(Unknown
>>>> Source)
>>>>       at
>>>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
>>>>       ... 31 more
>>>> Caused by: java.lang.ClassCastException:
>>>> com.cname.rules.model.common.EmployeeDetailsRulesModel cannot be cast
>>>> to
>>>> com.cname.cbis.domain.update.Account
>>>>       at
>>>> org.drools.base.com.cname.cbis.domain.update.Account1384796854$getAccountStartDate.getValue(Unknown
>>>> Source)
>>>>       at
>>>> org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:87)
>>>>       at org.drools.rule.Declaration.getValue(Declaration.java:233)
>>>>       at
>>>> com.cname.rules.validation.business.Rule_employeeContributionStartDateAfterAccountStartDate_357b04c70dac4f469ea9cedd93d15da7Eval1InvokerGenerated.evaluate(Unknown
>>>> Source)
>>>>       at
>>>> com.cname.rules.validation.business.Rule_employeeContributionStartDateAfterAccountStartDate_357b04c70dac4f469ea9cedd93d15da7Eval1Invoker.evaluate(Unknown
>>>> Source)
>>>>       at
>>>> org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114)
>>>>       ... 49 more
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://drools.46999.n3.nabble.com/ClassCastException-after-migrating-from-Drools-4-x-to-v5-5-tp4022292p4022382.html
>>>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list