Download Blaze Trial
Follow FICO
LinkedIn   Twitter   Youtube
Close To access this section, please choose the Community Neighborhood in which you have the most interest.

» Business Rules Management
» Collections & Recovery
» Fraud Management
» Risk Management
» Scoring
Close To access this section, please choose the Community Neighborhood in which you have the most interest.

» Business Rules Management
» Collections & Recovery
» Fraud Management
» Risk Management
» Scoring
Reply
Contributor
ssah
Posts: 15
Registered: ‎03-13-2012
Accepted Solution

NdAssertionException: Assertion failed

 

I am using Blaze 7.0 with a Java OM. Here is the scenaio..

 

 

Parent Abstract Class: AccountData

SubClass: ConsumerAccountData

 

I am trying to initizalize the object so that I can use it in my testing. Here is my code.

 

 

{accountData =  a ConsumerAccountData initially { 
  currentScore = 999.
}.

 

 

 

It work for the first time. When I run it the second time, I get the following error

 

 

java.lang.NullPointerException
 at com.blazesoft.engines.rules.NdEvaluationException.WjHXHlA(:177)
 at com.blazesoft.engines.rules.NdEvaluationException.WjHXHmB(:216)
 at com.blazesoft.engines.rules.NdEvaluationException.WjHHdQP(:108)
 at com.blazesoft.engines.rules.NdEvaluationException.<init>(:131)
 at com.blazesoft.engines.rules.NdEvaluationException.WjHHdQQ(:296)
 at com.blazesoft.engines.rules.NdEvaluationException.WjHHdQR(:311)
 at com.blazesoft.engines.rules.NdEvaluationContext.evaluationException(:795)
 at com.blazesoft.engines.rules.NdEvaluationContext.WjHFaNM(:822)
 at com.blazesoft.engines.rules.NdObject.WjHBKMM(:5128)
 at com.blazesoft.engines.rules.NdObject.WjHBKUU(:5265)
 at com.blazesoft.engines.rules.NdObject.WjHBKXX(:5321)
 at com.blazesoft.engines.rules.NdEvaluationContext.WjHHQEV(:300)
 at com.blazesoft.engines.rules.NdEvaluationContext.WjHLPgB(:330)
 at com.blazesoft.engines.rules.NdEvaluationContext.free(:365)
 at com.blazesoft.engines.rules.NdScriptContext.WjHJsdG(:2829)
 at com.blazesoft.engines.rules.NdScriptContext.WjHCLrW(:2784)
 at com.blazesoft.engines.rules.NdScriptContext.reset(:2987)
 at com.blazesoft.engines.rules.NdScriptContext.initInternal(:2703)
 at com.blazesoft.engines.rules.NdScriptContext.initialize(:2676)
 at com.blazesoft.engines.rules.NdRuleAgent.initialize(:5866)
 at com.blazesoft.proxy.rules.local.NdRuleAgentDevProxyLocalBase.initialize(:281)
 at com.blazesoft.devtools.rules.NdDevSessionManager$WjHDqbE.run(:1786)
 at java.lang.Thread.run(Unknown Source)

 

 

Thereafter I get the following error..

 

com.blazesoft.util.NdAssertionException: Assertion failed.
 at com.blazesoft.util.NdBaseObject.advAssert(:188)
 at com.blazesoft.engines.rules.NdObject.WjHBKzO(:2054)
 at com.blazesoft.engines.rules.NdObject.WjHBKXX(:5327)
 at com.blazesoft.engines.rules.NdEvaluationContext.WjHHQEV(:300)
 at com.blazesoft.engines.rules.NdEvaluationContext.WjHLPgB(:330)
 at com.blazesoft.engines.rules.NdEvaluationContext.free(:365)
 at com.blazesoft.engines.rules.NdScriptContext.WjHJsdG(:2829)
 at com.blazesoft.engines.rules.NdScriptContext.WjHCLrW(:2784)
 at com.blazesoft.engines.rules.NdScriptContext.reset(:2987)
 at com.blazesoft.engines.rules.NdScriptContext.initInternal(:2703)
 at com.blazesoft.engines.rules.NdScriptContext.initialize(:2676)
 at com.blazesoft.engines.rules.NdRuleAgent.initialize(:5866)
 at com.blazesoft.proxy.rules.local.NdRuleAgentDevProxyLocalBase.initialize(:281)
 at com.blazesoft.devtools.rules.NdDevSessionManager$WjHDqbE.run(:1786)
 at java.lang.Thread.run(Unknown Source)

 

 

 

This cycle repeats.. If I re-compile and run, it runs for the first time and then again throws errors.

 

Kindly advise.

 

Shubham

 

Credit Risk Analyst
PayPal, Inc.
Valued Contributor
Posts: 169
Registered: ‎03-12-2009

Re: NdAssertionException: Assertion failed

Hi Shubham,

 

     You have to instantiate it first the syntax should be more like this:

    

{accountData =  some ConsumerAccountData initially a ConsumerAccountData initially { 
  currentScore = 999.
}

 

     The "some" instantiates an instance of the class (like "new"),  "initially a ConsumerAccountData" creates an initial value for all of the properties and finally the "initially { currentScore = 999} will initialize your currentScore property.

 

     Tom Sheckells

     Business Rules Consulting, Inc.

Contributor
ssah
Posts: 15
Registered: ‎03-13-2012

Re: NdAssertionException: Assertion failed

Hi Tom,

 

Thanks for your reply. I alreadt tried that approach. That gave me another exception as follows

 

 

 

 

com.blazesoft.engines.rules.NdEvaluationException: Evaluation error  while evaluating "{accountData = (a ConsumerAccountData initially {it.creditScore = 100})}" in RechAccountData#1
java.lang.RuntimeException: Failed to remove external object 'ConsumerAccountData#1' of class 'ConsumerAccountData'.
The object's hash code has probably changed.
 at com.blazesoft.engines.rules.NdObject.WjHBKzO(:2104)
 at com.blazesoft.engines.rules.NdObject.WjHBKXX(:5327)
 at com.blazesoft.engines.rules.NdEvaluationContext.WjHHQEV(:300)
 at com.blazesoft.engines.rules.NdEvaluationContext.WjHLPgB(:330)
 at com.blazesoft.engines.rules.NdEvaluationContext.free(:400)
 at com.blazesoft.engines.rules.expressions.WjHAPdD.WjHLPlX(:237)
 at com.blazesoft.engines.rules.expressions.WjHAPdD.WjHBdED(:199)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOwZ(:572)
 at com.blazesoft.engines.rules.expressions.NdExpression.evaluate(:539)
 at com.blazesoft.engines.rules.expressions.NdInstantiationExpression.WjHBdED(:228)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOvY(:502)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOwZ(:592)
 at com.blazesoft.engines.rules.expressions.NdExpression.catchEvaluate(:1168)
 at com.blazesoft.engines.rules.expressions.NdSimplePropertyAssignmentStatement.WjHBdED(:123)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOvY(:502)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOwZ(:592)
 at com.blazesoft.engines.rules.expressions.NdExpression.catchEvaluate(:1168)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOxA(:1240)
 at com.blazesoft.engines.rules.expressions.NdExpression.evaluateAction(:1223)
 at com.blazesoft.engines.rules.expressions.WjHAPdD.WjHLPlX(:224)
 at com.blazesoft.engines.rules.expressions.WjHAPdD.WjHBdED(:199)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOwZ(:572)
 at com.blazesoft.engines.rules.expressions.NdExpression.evaluate(:539)
 at com.blazesoft.engines.rules.expressions.NdInstantiationExpression.WjHBdED(:228)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOvY(:502)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOwZ(:592)
 at com.blazesoft.engines.rules.expressions.NdExpression.catchEvaluate(:1168)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOxA(:1240)
 at com.blazesoft.engines.rules.expressions.NdExpression.evaluateAction(:1223)
 at com.blazesoft.engines.rules.expressions.WjHAPdD.WjHLPlX(:224)
 at com.blazesoft.engines.rules.expressions.WjHAPdD.WjHBdED(:199)
 at com.blazesoft.engines.rules.expressions.NdExpression.WjHLOwZ(:572)
 at com.blazesoft.engines.rules.expressions.NdExpression.evaluate(:539)
 at com.blazesoft.engines.rules.expressions.NdExpression.evaluateStatement(:1265)
 at com.blazesoft.engines.rules.WjHBIEZ.WjHBIER(:200)
 at com.blazesoft.engines.rules.NdScriptContext.initInternal(:2713)
 at com.blazesoft.engines.rules.NdScriptContext.initialize(:2676)
 at com.blazesoft.engines.rules.NdRuleAgent.initialize(:5866)
 at com.blazesoft.proxy.rules.local.NdRuleAgentDevProxyLocalBase.initialize(:281)
 at com.blazesoft.devtools.rules.NdDevSessionManager$WjHDqbE.run(:1786)
 at java.lang.Thread.run(Unknown Source)

 

 

 

Thanks,

Shubham

Credit Risk Analyst
PayPal, Inc.
Valued Contributor
Posts: 169
Registered: ‎03-12-2009

Re: NdAssertionException: Assertion failed

Hi Shubham,

 

     Sometimes, it is the little things that can cause the most agravation.  Especially when it is missed several times because I rush.  In looking carefully at your statement, you are are trying to assign a new instance to the class.  Try something like this (note the new name):

 

  acctData is some ConsumerAccountData initally a ConsumerAccountData initially {

     it.creditScore = 456}; 

 

     That might produce better results.

 

     Tom Sheckells

     Business Rules Consulting, Inc.

Contributor
ssah
Posts: 15
Registered: ‎03-13-2012

Re: NdAssertionException: Assertion failed

Hi Tom,

 

I tried that without any luck.

 

Here is my code

 

 

 

{ acctData is some ConsumerAccountData initially a ConsumerAccountData initially {
  it.creditScore = 456}; 
}

 

 

 

 

Here is the error

 

 

[

+] [->] com.blazesoft.engines.rules.NdEvaluationException: Evaluation error

Failed to remove external object 'ConsumerAccountData#1' of class 'ConsumerAccountData'.

The object's hash code has probably changed. while evaluating "{acctData = (a ConsumerAccountData initially {it.creditScore = 456})}" in RechAccountData#1

 

 

 

 

When placed inside a try catch, I get the following message

 

 

error: Expression produces unexpected value: null.

 

 

 

Thanks,

Shubham

 

 

 

 

 

 

 

Credit Risk Analyst
PayPal, Inc.
Contributor
kharsha
Posts: 20
Registered: ‎05-14-2011

Re: NdAssertionException: Assertion failed

[ Edited ]

Hi Shubham,

 

"The object's hash code has probably changed. while evaluating" error occurs when you have the BOM classes override the default methods like hashcode and equals (provided by the Java Object class) where you update the hashcode of the object based on the value of a property or a set of properties and you try to change the property within the rules which was used in computation of hashcode.

 

To overcome this error you can remove the overridden methods of hashcode and equals from your Java BOM classes or use the "NdUserDefinedMutableJavaValueClasses.properties" with the class information like below:

 

#User defined classes
<fully qualified Java class name"=true

 

Place this properties file under the package com/blazesoft/objects/java in your BOM Jar file. This configuration provides information to the Blaze execution engine to use the hashcode and equals implementations of Java Object class and resolves the error.

 

Thanks,

Harsha Kolla

BRMS Lead Consultant

DAASL


Contributor
ssah
Posts: 15
Registered: ‎03-13-2012

Re: NdAssertionException: Assertion failed

Thanks for your reply. I will definitely give it a try and post an update soon.

 

Thanks,

Shubham

 

Credit Risk Analyst
PayPal, Inc.
DM-Forums Moderator
Posts: 472
Registered: ‎10-02-2008

Re: NdAssertionException: Assertion failed

Just for completeness:

Kharshas answer is obviously correct, but there is another option: The specification/contract for hashCode and equals for Java objects state that they should be based only on immutable properties of the object, as they represent the identity of the object. In other words, you can rewrite the hashCode/equals methods of the offending class to honor that contract. That should also solve your problem, though it is not always possible/easy (hence the options outlined by kharsha).

 

Regards,

Jostein

Contributor
ssah
Posts: 15
Registered: ‎03-13-2012

Re: NdAssertionException: Assertion failed

Hi Guys,

 

The java BOM for the parent class for ConsumerAccountData does overrides the hashcode method. All the above solutions in this forum suggest to change code for the BOM class which is not possible.

 

Is there a work around in this situation which will allow me to keep the code for the jar file as is? Do I need to open a ticket for this issue? Kindly advise.

 

 

 

 

@Jostein: From your reply above, it seems that you mean that hashCode method cannot be implemented at a place where the identity of the object changes. However, I found this on wikipedia..

 

"The general contract for overridden implementations of this method is that they behave in a way consistent with the same object's equals() method: that a given object must consistently report the same hash value (unless it is changed so that the new version is no longer considered "equal" to the old), and that two objects which equals() says are equal must report the same hash value. There's no requirement that hash values be consistent between different Java implementations, or even between different execution runs of the same program, and while two unequal objects having different hashes is very desirable, this is not mandatory (that is, the hash function implemented need not be a perfect hash)."

 

Thanks,

Shubham

 

 

 

Credit Risk Analyst
PayPal, Inc.
Contributor
kharsha
Posts: 20
Registered: ‎05-14-2011

Re: NdAssertionException: Assertion failed

[ Edited ]

Hi Shubham,

 

The solution I have oulined in my previous post does not require a change to the BOM implementation. Blaze uses the class information set in the properties file to use the hashcode and equals implemetations of the Java Object which shall resolve your problem.

 

On a different note regarding using the mutable properties in defining the hashcode- it is not a good idea to do so while using such classes within collections.

 

Good Luck.

 

Harsha