2013-02-21 23 views
0

我想从activiti序列流中调用一个方法,但是我得到下面的错误,有人可以帮我解决这个问题吗?错误 - 试图使用executionListener时无法解析标识符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:在org.activiti.engine.impl.juel无法解析标识 'EscalationListener' 。 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 
    } 

} 

回答

2

您需要添加EscalationListener过程变量:

runtimeService.startProcessInstanceByKey("someKey", processVariables); 

processVariables是你把EscalationListener对象

一个Map<String, Object>

runtimeService.setVariable(yourExecutionId, "escalationListener" , new EscalationListener()); 

您也可以在启动过程之前添加过程变量或将其声明为Spring bean以在进程定义中访问它:

<bean id="EscalationListener" class="com.test.activiti.listener.EscalationListener" > 
0
<activiti:executionListener 
       expression="${EscalationListener.escalate(execution, 'kermit')}" 
       event="end" /> 

尝试在escalationListener这里改变EscalationListener。有时候我有时会因为这个问题而出问题。

不幸的是,这个PropertyNotFoundException: Cannot resolve identifier发生了很多,当你有错误。至少对我而言,这不会帮助你...

相关问题