[rules-users] ClassCastException and "from collect" keyword issue?

Tan, Kevin Kevin.Tan at morganstanley.com
Wed Jan 30 19:08:41 EST 2013


Hi rules users,

I am having a problem with Drools 5.1.1 recently. The exception we had is:

java.lang.ClassCastException:
d2.rules.state.EvaluateRule cannot be cast to d2.autorating.data.model.Account
org.drools.runtime.rule.ConsequenceException: rule: DERIVE_COLLAT_MECHANISM_PLEDGE

Our rules are listed as below:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rule "DERIVE_COLLAT_MECHANISM_PLEDGE"
no-loop true
salience 19991
    when
       $RatingData : RatingRuleFact()
       $contract : Contract()
       $csaDoc : Document(documentId == $contract.csaId && status == "Final/Signed")
       (EvaluateRule(ruleName == "INSCOPE))
    then
        RuleProcessingOutput ruleOutput = $RatingData.getRuleOutput();
        RuleResult result = new RuleResult(drools.getRule().getName(), $contract.getContractId(), $RatingData.getPrincipalPartyCountry());
        ruleOutput.addRuleResult(result);
        $contract.setCollateralMechanism(result.getRuleOutputText());
        insertLogical(new EvaluateRule(drools.getRule().getName()));
end

rule "EXC_COLLAT_HOLDING_ARRANGEMENT"
no-loop true
salience 19985
    when
       $RatingData : RatingRuleFact()
       $contract : Contract()
       $noHoldingAgreementAccts : ArrayList()
       from collect ( Account(collatNetId == $contract.contractId,
                    businessUnit not in ("COMM", "FID", "FX", "IED", "SECLENDING", "SWAPS")) from $contract.collatAccounts
       )
       EvaluateRule(ruleName == "INSCOPE")
    then
        RuleProcessingOutput ruleOutput = $RatingData.getRuleOutput();
        for (Object obj : $noHoldingAgreementAccts) {
            Account acct = (Account) obj;
            if (acct.getDp2Account() != null) {
                RuleResult result = new RuleResult(drools.getRule().getName(), $contract.getContractId(), $RatingData.getPrincipalPartyCountry());
                result.setAccountId(acct.getDp2Account().getAccountId());
                result.setRuleOutputText("BU has no Data");
                ruleOutput.addRuleResult(result);
            }
        }
        if ($noHoldingAgreementAccts.size() > 0) {
            insertLogical(new EvaluateRule(drools.getRule().getName()));
        }
end
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


*         In object Account(), we did not have any EvaluateRule() object in it.

*         We also noticed after the "from collect" key word there are EvaluateRule() object defined after it(but the purpose is just to determine if this object exist or not in the Working Memory), in the LHS of each rule file.

*         In the variable $noHoldingAgreementAccts, we are not supposed to see the object - EvaluateRule (BUT the exception is showing it is trying to cast EvaluateRule into Account)


My question is are there any known problems/issues with the following

-          Drools rule compilers

-          Key word from collect

-          Rules production memory

-          Version 5.1.1

that can make this happen? Any ideas will be appreciated. Thanks.


Kevin Tan
Morgan Stanley | Enterprise Data & Services
700 Rue Wellington | Floor 04
Montreal, QC H3C 3S4
Phone: +1 514 876-5756
Kevin.Tan at morganstanley.com<mailto:Thanh.Dang at morganstanley.com>



________________________________

NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130131/24048ea8/attachment.html 


More information about the rules-users mailing list