我在Spring + JSF项目中使用Activiti引擎,我正在尝试通过我的process.BPMN20.xml调用方法并将参数传递给我的工作流:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
targetNamespace="http://www.bpmnwithactiviti.org"
xmlns:activiti="http://activiti.org/bpmn">
<process id="my-process" name="my-process">
<startEvent id="startEvent" name="Start" activiti:formKey="taskForm_newOrder.jsf" />
<sequenceFlow id="toValidateTask" sourceRef="startEvent" targetRef="validateTask"/>
<serviceTask id="validateTask" activiti:expression="#{operationController.sayHello()}" >
<extensionElements>
<activiti:field name="input" expression="${adminModele.operationLabel}" />
</extensionElements>
</serviceTask>
<sequenceFlow id="toCompletedOrderTask" sourceRef="validateTask" targetRef="completeOrderTask"/>
<userTask id="completeOrderTask" name="Complete order" activiti:assignee="${adminModele.operationLabel}" activiti:formKey="taskForm_completeOrder.jsf">
<documentation>Completing order for book with isbn : ${adminModele.operationLabel} </documentation>
</userTask>
<sequenceFlow id="toApproveTask" sourceRef="completeOrderTask" targetRef="approveTask"/>
<serviceTask id="approveTask" activiti:expression="#{bookOrder.validates()}" />
<sequenceFlow id="toEndEvent" sourceRef="approveTask" targetRef="endEvent"/>
<endEvent id="endEvent" name="End"/>
</process>
</definitions>
在这里我将值设置为bookOrder
bookOrder = new BookOrder();
bookOrder.setIsbn("123");
sayHello(); // this call doesn't return an error
sayHello()方法:
public void sayHello(){
System.out.println("SayHello ..."+bookOrder.getIsbn());
}
当我调用sayHello()时,它显示我想要的意味着bookOrder.getIsbn()
不为空,但是当Activiti引擎在完成整个过程时调用它时,我得到:
javax.faces.el.EvaluationException: org.activiti.engine.ActivitiException: Error while evaluating expression: #{operationController.sayHello()}
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
Caused by: java.lang.NullPointerException
at ma.net.s2m.selectsystem.web.controller.admin.OperationController.sayHello(OperationController.java:887)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.activiti.engine.impl.javax.el.BeanELResolver.invoke(BeanELResolver.java:483)
任何想法是什么问题以及如何解决?