2013-02-21 21 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發生了很多,當你有錯誤。至少對我而言,這不會幫助你...

相關問題