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@morganstanley.com