Hi Wolfgang,
Thanks for your reply. Yes - this is the only place where both d2.rules.state.EvaluateRule
and d2.autorating.data.model.Account are referenced. That's why we finally locate the
classcastexception in this line:
Account acct = (Account) obj;
The weird thing is we are not able to replicate this error during the second time run in
our program. We also searched and found some similar issues:
http://drools.46999.n3.nabble.com/accumulate-vs-collect-td1884308.html
http://lists.jboss.org/pipermail/rules-users/2009-June/009484.html
http://drools.46999.n3.nabble.com/unexpected-ClassCastException-when-deal...
Please advise.
-Kevin
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Wolfgang Laun
Sent: Thursday, January 31, 2013 10:29 AM
To: Rules Users List
Subject: Re: [rules-users] ClassCastException and "from collect" keyword issue?
Is rule "EXC_COLLAT_HOLDING_ARRANGEMENT" *absolutely* the only one where both
d2.rules.state.EvaluateRule and d2.autorating.data.model.Account are referenced?
-W
On 31/01/2013, Tan, Kevin <Kevin.Tan(a)morganstanley.com> wrote:
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<mailto:Thanh.Dang@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.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--------------------------------------------------------------------------------
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.