在JBPM4.3允许配置变量搜索范围图下:
<process-engine-context> <script-manager default-expression-language="juel" default-script-language="juel" read-contexts="execution,transaction,process-engine,spring" write-context=""> <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" /> <script-language name="bsh" factory="org.jbpm.pvm.internal.script.BshScriptEngineFactory" /> <script-language name="groovy" factory="org.jbpm.pvm.internal.script.GroovyScriptEngineFactory" /> </script-manager> </process-engine-context>
“read-contexts="execution,transaction,process-engine,spring" 指定搜索范围,但实际上不起作用,实际的搜索范围是运行环境(Environment)中动态加入的Context,如[execution, transaction, process-engine, spring],但不同的执行环境中会有不同,如果没有和Spring集成,自然不会有spring context,有时候execution也不会有,比如你在启动流程时设置流程的超时时间(注意:这里不是节点超时)使用变量表达式,虽然你在启动流程时把变量传入了,但由于初始化流程超时时还没有把ExcutionContext(传入的变量放在这里的)加入到Environment中,因此script-manager 会报异常如下:
javax.el.PropertyNotFoundException: Cannot find property d38b041b88b711dfab700016eca5d82f at de.odysseus.el.util.SimpleResolver.get(SimpleResolver.java:106) at de.odysseus.el.util.SimpleResolver.getValue(SimpleResolver.java:126) at de.odysseus.el.tree.impl.ast.AstIdentifier.eval(AstIdentifier.java:69) at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:42) at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:29) at de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:120) at org.jbpm.pvm.internal.script.JuelScriptEngine.evalExpr(JuelScriptEngine.java:176) ... 68 more