Renato,
You stumbled on a bug that was still in Drools 5.0. There are issues in
using an Integer variable inside constraints (as the constraint will try
to interpret it as a String). This has been fixed a long time ago in
the snapshot releases:
http://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/tr...
As workaround, you could also change the type of your variable to Object
and then use java.lang.Integer as class.
Kris
Quoting Renato Herebia <renato.herebia(a)dextra-sw.com>:
Kris, thanks for your answer...
I've tried to access the variable in a split constraint (return count
!= 1;)
with mvel dialect and I got this trace in runtime:
Uncaught exception on client
java.lang.RuntimeException: unable to execute ReturnValueEvaluator
at
org.drools.workflow.instance.impl.ReturnValueConstraintEvaluator.evaluate(ReturnValueConstraintEvaluator.java:124)
at
org.drools.workflow.instance.node.SplitInstance.internalTrigger(SplitInstance.java:62)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:111)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:141)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:128)
at
org.drools.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerCompleted(ExtendedNodeInstanceImpl.java:37)
at
org.drools.workflow.instance.node.EventBasedNodeInstance.triggerCompleted(EventBasedNodeInstance.java:96)
at
org.drools.workflow.instance.node.EventBasedNodeInstance.triggerCompleted(EventBasedNodeInstance.java:77)
at
org.drools.workflow.instance.node.WorkItemNodeInstance.triggerCompleted(WorkItemNodeInstance.java:192)
at
org.drools.workflow.instance.node.HumanTaskNodeInstance.triggerCompleted(HumanTaskNodeInstance.java:74)
at
org.drools.workflow.instance.node.WorkItemNodeInstance.workItemCompleted(WorkItemNodeInstance.java:246)
at
org.drools.workflow.instance.node.WorkItemNodeInstance.signalEvent(WorkItemNodeInstance.java:222)
at
org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:258)
at
org.drools.process.instance.impl.DefaultWorkItemManager.completeWorkItem(DefaultWorkItemManager.java:96)
at
org.drools.process.workitem.wsht.WSHumanTaskHandler$GetCompletedTaskResponseHandler.execute(WSHumanTaskHandler.java:282)
at
org.drools.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:67)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:752)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
at
org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:379)
at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:173)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:616)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:408)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:578)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:540)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:532)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:58)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:857)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.ClassCastException: java.lang.Integer cannot be
> cast to
> java.lang.String
at
org.mvel2.math.MathProcessor.getInternalNumberFromType(MathProcessor.java:555)
> at
> org.mvel2.math.MathProcessor._doOperations(MathProcessor.java:155)
> at
> org.mvel2.math.MathProcessor.doOperations(MathProcessor.java:79)
at
org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:102)
> at
> org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:37)
> at
> org.mvel2.ast.ReturnNode.getReducedValueAccelerated(ReturnNode.java:45)
> at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:107)
> at org.mvel2.MVEL.executeExpression(MVEL.java:978)
at
org.drools.base.mvel.MVELReturnValueEvaluator.evaluate(MVELReturnValueEvaluator.java:110)
at
org.drools.workflow.instance.impl.ReturnValueConstraintEvaluator.evaluate(ReturnValueConstraintEvaluator.java:121)
> ... 36 more
>
> With Java dialect I got a problem when I add the rule flow to the
> KnowledgeBuilderFactory:
>
> java.lang.RuntimeException: Process Compilation error :
> org.drools.lang.descr.ProcessDescr@69695f
> com/sample/Process_com_sample_0.java (9:387) : Incompatible
> operand
> types String and int
>
> at com.sample.ProcessTest.readKnowledgeBase(ProcessTest.java:81)
> at com.sample.ProcessTest.main(ProcessTest.java:30)
>
>
> Using action node, I could get the variable process with mvel dialect
> in
> action just calling:
>
> System.out.println("The counting is: " + count);
>
> If I use Java dialect with the same System.out, I got this problem
> after add
> the rule flow to the KnowledgeBuilderFactory:
>
> java.lang.RuntimeException: unable to execute Action
at
org.drools.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:56)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:111)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:141)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:128)
at
org.drools.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)
at
org.drools.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:111)
at
org.drools.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:16)
at
org.drools.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:185)
at
org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:230)
at
org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1639)
at
org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:272)
> at com.sample.ProcessTest.main(ProcessTest.java:42)
> Caused by: java.lang.ClassCastException: java.lang.Integer cannot be
> cast to
> java.lang.String
at
com.sample.Process_com_sample_0Action0Invoker.execute(Process_com_sample_0Action0Invoker.java:18)
at
org.drools.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:54)
... 12 more
In this scenario, my doubts are:
- It's necessary any configuration for the access in action/split
nodes to
process variables?
- How can I do that?
Thanks in advance.
--
Renato Herebia
Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm