我正在尝试从activiti序列流中调用一个方法,但是我收到以下错误,有人可以帮我解决这个问题吗?
<sequenceFlow id="finalTask" name="finalTask" sourceRef="chargeAccount" targetRef="theEnd">
<extensionElements>
<activiti:executionListener
expression="${EscalationListener.escalate(execution, 'kermit')}"
event="end" />
</extensionElements>
</sequenceFlow>
错误:
引起:org.activiti.engine.impl.javax.el.PropertyNotFoundException:无法解析标识符'EscalationListener' 在org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:8
Java代码:
import org.activiti.engine.HistoryService;
import org.activiti.engine.delegate.DelegateExecution;
public class EscalationListener {
HistoryService historyService;
public void escalate(DelegateExecution execution, String otherTaskId)
throws Exception {
historyService.createHistoricTaskInstanceQuery().taskOwner(otherTaskId)
.finished();
//System.out.println("called history service" + otherTaskId);
// do some stuff with the task
}
}
答案 0 :(得分:2)
您需要添加EscalationListener
作为流程变量:
runtimeService.setVariable(yourExecutionId, "escalationListener" , new EscalationListener());
您还可以在开始流程之前添加流程变量:
runtimeService.startProcessInstanceByKey("someKey", processVariables);
processVariables是Map<String, Object>
,您可以在其中放置EscalationListener
对象
或将其声明为Spring bean以在流程定义中访问它:
<bean id="EscalationListener" class="com.test.activiti.listener.EscalationListener" >
答案 1 :(得分:0)
<activiti:executionListener
expression="${EscalationListener.escalate(execution, 'kermit')}"
event="end" />
尝试在此EscalationListener
更改escalationListener
。有时因为这个问题我有问题。
可悲的是,当你遇到错误时,这个PropertyNotFoundException: Cannot resolve identifier
会发生很多。至少对我而言,它并没有帮助你......