[jboss-jira] [JBoss JIRA] (JBRULES-2875) Exception executing predicate with binding variable and or predicate

Chris Dolan (JIRA) jira-events at lists.jboss.org
Fri Apr 27 08:44:18 EDT 2012


    [ https://issues.jboss.org/browse/JBRULES-2875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12688343#comment-12688343 ] 

Chris Dolan commented on JBRULES-2875:
--------------------------------------

I suspect this has the same root cause as https://issues.jboss.org/browse/JBRULES-3482. The unexpected ClassCastException looks very similar. It sure looks like Drools is trying to use the String() match result to assign to $entiteId, which looks like an off-by-one to me.
                
> Exception executing predicate with binding variable and or predicate
> --------------------------------------------------------------------
>
>                 Key: JBRULES-2875
>                 URL: https://issues.jboss.org/browse/JBRULES-2875
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core
>    Affects Versions: 5.1.1.FINAL
>         Environment: Windows XP / DEBIAN / Eclipse 3.5.1
>            Reporter: alexandre Cordevant
>            Assignee: Mark Proctor
>            Priority: Critical
>
> Exception executing predicate with binding variable and or predicate
> When I execute this kind of rule :
> (where field id from Object Entity is an Integer.)
> rule "test"
> salience 20
> when
> 	(String() or Double())
> 	$entity:Entity()
> 	DroolsTest(entity.id == $entity.id )
> then
> 	System.out.println( "it works !" );
> end
> I got this exception :
> Exception in thread "main" org.drools.RuntimeDroolsException: Exception executing predicate entite.id == $entite.id
> 	at org.drools.rule.PredicateConstraint.isAllowedCachedLeft(PredicateConstraint.java:302)
> 	at org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaConstraints.java:142)
> 	at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:83)
> 	at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
> 	at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:64)
> 	at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:85)
> 	at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
> 	at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138)
> 	at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:148)
> 	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
> 	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
> 	at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1174)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1123)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:917)
> 	at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
> 	at com.agysoft.marco.tools.tuOneShot.marcometier.drools.DroolsTest.main(DroolsTest.java:57)
> Caused by: [Error: unable to resolve method: java.lang.String.id() [arglength=0]]
> [Near : {... Unknown ....}]
>              ^
> [Line: 1, Column: 0]
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:932)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:592)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:311)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:137)
> 	at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:137)
> 	at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:111)
> 	at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
> 	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:104)
> 	at org.mvel2.MVEL.executeExpression(MVEL.java:1001)
> 	at org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:91)
> 	at org.drools.rule.PredicateConstraint.isAllowedCachedLeft(PredicateConstraint.java:295)
> 	... 16 more
> this rule Works :
> rule "test"
> salience 20
> when
> 	$entity:Entity()
> 	DroolsTest(entity.id == $entity.id )
> then
> 	System.out.println( "it works !" );
> end
> this rule Works :
> rule "test"
> salience 20
> when
>         (String() or Double())
> 	$entity:Entity()
> 	DroolsTest(entity.id == $entity.id )
> then
> 	System.out.println( "it works !" );
> end
> ---------------------------------------------------------------------------------------------------
> variant case with another Exception :
> rule "test"
> salience 20
> when
> 	(String() or Double())
> 	Entite($entiteId:id)
> 	DroolsTest(entite.id == $entiteId )
> then
> 	System.out.println( "it works !" );
> end
> throw this Exception Stack :
> Exception in thread "main" org.drools.RuntimeDroolsException: Exception executing predicate entite.id == $entiteId
> 	at org.drools.rule.PredicateConstraint.isAllowedCachedLeft(PredicateConstraint.java:302)
> 	at org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaConstraints.java:142)
> 	at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:83)
> 	at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
> 	at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:64)
> 	at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:85)
> 	at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
> 	at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138)
> 	at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:148)
> 	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
> 	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
> 	at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1174)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1123)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:917)
> 	at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
> 	at com.agysoft.marco.tools.tuOneShot.marcometier.drools.DroolsTest.main(DroolsTest.java:57)
> Caused by: [Error: java.lang.String cannot be cast to com.agysoft.marco.tools.tuOneShot.marcometier.drools.Entite]
> [Near : {... Unknown ....}]
>              ^
> [Line: 1, Column: 0]
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:387)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:137)
> 	at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:137)
> 	at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:111)
> 	at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
> 	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:104)
> 	at org.mvel2.MVEL.executeExpression(MVEL.java:1001)
> 	at org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:91)
> 	at org.drools.rule.PredicateConstraint.isAllowedCachedLeft(PredicateConstraint.java:295)
> 	... 16 more
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to com.agysoft.marco.tools.tuOneShot.marcometier.drools.Entite
> 	at org.drools.base.com.agysoft.marco.tools.tuOneShot.marcometier.drools.Entite4694228$getId.getIntValue(Unknown Source)
> 	at org.drools.base.extractors.BaseIntClassFieldReader.getValue(BaseIntClassFieldReader.java:52)
> 	at org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:91)
> 	at org.drools.rule.Declaration.getValue(Declaration.java:228)
> 	at org.drools.base.mvel.DroolsMVELPreviousDeclarationVariable.getValue(DroolsMVELPreviousDeclarationVariable.java:83)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:454)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:311)
> 	... 24 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list