cancel
Showing results for 
Search instead for 
Did you mean: 

calling getter inside method Returns java.lang.NullPointerException with Activiti Engine

ilyass_act
Champ on-the-rise
Champ on-the-rise

i'm tryin to implement my own java logic using SPRING + JSF with activiti , this my BPMN file :

<?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>

the sayHello() :

public void sayHello(){

System.out.println("SayHello ................."+bookOrder.getIsbn());

}

 when i do a simple call to sayHello ()  it displays what i want but when the ServiceTask calls sayHello i get  JavaNullPointerException , means my bookOrder object is null .

Any ideas how to deal with this problem

13 REPLIES 13

gdharley
Elite Collaborator
Elite Collaborator

Nope, these are simple spring beans and need to be declared in the spring context.

For example @Service("bookOrder") won't work ? 

gdharley
Elite Collaborator
Elite Collaborator

If you're using spring annotation based configuration then this is what you would do.

If you are using xml based configuration (which is what it appears you are doing) then you would use the activiti.cfg.xml

Thank you Geg ,
Let's say you have a ServiceTask where you pass expression , activiti:expression="${operationController.sayHello()}" .
and your method implements something like this :
public void sayHello(){

System.out.println("the isbn :"+bookOrder.getIsbn()); 

}

the value of ISBN comes from a JSF Form , How would you implement this ?