-
Bug
-
Resolution: Done
-
Major
-
jBPM 3.1.1
-
None
jPBM allows to use process variables in script. Process variables could be defined in root token context or created/redefined in sub token context.
Process variable value in script is always resolved in a root token context, so if sub-token variable is passed to script, exception is thrown telling that undefined argument is referenced in script (see below).
I believe following code should be changed to fix this problem
method - org.jbpm.graph.action.Script.createInputMap(ExecutionContext)
line 88 - Map variables = contextInstance.getVariables(); ===> Map variables = contextInstance.getVariables(executionContext.getToken());
line 107 - Object variableValue = contextInstance.getVariable(variableName); ===> Object variableValue = contextInstance.getVariable(variableName, executionContext.getToken());
------------Script definition ----------
<process-definition xmlns="http://jbpm.org/3/jpdl" name="local_var_cond">
...
<state name="WaitState_2">
<transition name="trans_14" to="Decision_1">
<script accept-propagated-events="yes" name="Script_1">
<variable access="read,write" mapped-name="x1" name="x"/>
<expression>System.out.println (x1);</expression>
</script>
</transition>
</state>
...
</process-definition>
------------ Stack trace ------------------------------------------------
Caused by: org.jbpm.JbpmException: can't evaluate beanshell script 'System.out.println (x1);'
at org.jbpm.graph.action.Script.eval(Script.java:139)
at org.jbpm.graph.action.Script.eval(Script.java:73)
at org.jbpm.graph.action.Script.execute(Script.java:62)
at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
... 20 more
Caused by: Sourced file: inline evaluation of: ``System.out.println (x1);'' : Undefined argument: x1 : at Line: 1 : in file: inline evaluation of: ``System.out.println (x1);'' : ( x1 )
at bsh.BSHArguments.getArguments(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at org.jbpm.graph.action.Script.eval(Script.java:130)
... 23 more