[rules-users] class Cast Exception when using OR (||) - Bug?

Arjun Dhar dhar_ar at yahoo.com
Mon Jul 30 11:53:30 EDT 2007


When I define a rule:

When
 cntct:Contact (initialized==true)
 exr:Relation( contact==cntct, 
               active:active==$1, 
               relationName=="Old")
Then
 contact.getStatus().setStatus(true);
 contact.getStatus().addToReasonTrace(drools.getRule().getName());
end

..The bove works.

BUT, when I do the following:

When
 cntct:Contact (initialized==true)
 exr:Relation( contact==cntct, 
               active:active==$1, 
               relationName=="Old")
 || Relation( contact==cntct, 
               active:active==$1, 
               relationName==null)
Then
 contact.getStatus().setStatus(true);
 contact.getStatus().addToReasonTrace(drools.getRule().getName());
end
... The script compiles anda stateless Session is created successfully, but at 
runtime/execution it fails with the exception:
java.lang.ClassCastException: com.arjun.brms.businessObjects.Contact
org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:75)
org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:141)
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple
(SingleTupleSinkAdapter.java:20)
org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:120)
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple
(SingleTupleSinkAdapter.java:20)
org.drools.reteoo.JoinNode.assertObject(JoinNode.java:162)
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject
(CompositeObjectSinkAdapter.java:317)
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject
(CompositeObjectSinkAdapter.java:308)
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject
(CompositeObjectSinkAdapter.java:308)
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)
org.drools.reteoo.Rete.assertObject(Rete.java:168)
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:70)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:848)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:822)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:623)

Class diagram:
~~~~~~~~~~~~~~~~
Contact<-- bi-directional association -->List<Relation>

Please advise! is this a bug?

thanks,
Arjun




More information about the rules-users mailing list