I am implement Log Event Listener using example given in user guide
<process name="EventListener" xmlns="http://jbpm.org/4.4/jpdl"> <on event="start"> <event-listener class="org.jbpm.examples.eventlistener.LogListener"> <field name="msg"><string value="start on process definition"/></field> </event-listener> </on> <start> <transition to="wait"/> </start> <state name="wait"> <on event="start"> <event-listener class="org.jbpm.examples.eventlistener.LogListener"> <field name="msg"><string value="start on activity wait"/></field> </event-listener> </on> <on event="end"> <event-listener class="org.jbpm.examples.eventlistener.LogListener"> <field name="msg"><string value="end on activity wait"/></field> </event-listener> </on> <transition to="park"> <event-listener class="org.jbpm.examples.eventlistener.LogListener"> <field name="msg"><string value="take transition"/></field> </event-listener> </transition> </state> <state name="park"/></process>and LogListener class like below public class LogListener implements EventListener { // value gets injected from process definition String msg; public void notify(EventListenerExecution execution) { List<String> logs = (List<String>) execution.getVariable("logs"); if (logs==null) { logs = new ArrayList<String>(); execution.setVariable("logs", logs); } logs.add(msg); execution.setVariable("logs", logs); }} but when I am testing using Junit ProcessInstance processInstance = executionService.startProcessInstanceByKey("EventListener");
public class LogListener implements EventListener { // value gets injected from process definition String msg; public void notify(EventListenerExecution execution) { List<String> logs = (List<String>) execution.getVariable("logs"); if (logs==null) { logs = new ArrayList<String>(); execution.setVariable("logs", logs); } logs.add(msg); execution.setVariable("logs", logs); }}
ProcessInstance processInstance = executionService.startProcessInstanceByKey("EventListener");
In above line getting Nullpointer Exception?
can any one help regards this , or any other reference to implement Event Listener in jbpm4
Thanks all
Reply to this message by going to Community
Start a new discussion in jBPM at Community