1 Reply Latest reply on Nov 5, 2010 1:40 PM by Michael Wohlfart

    Event Listener Problem

    dev.katiyar Newbie

      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");

      In above line getting Nullpointer Exception?

       

       

      can any one help regards this , or any other reference to implement Event Listener in jbpm4

       

       

      Thanks all

        • 1. Re: Event Listener Problem
          Michael Wohlfart Expert

          devendra katiyar wrote:

          [...]
          but when I am testing using Junit
          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

          [...]

           

          as far as I can tell from your writing most likely executionService is null, so how do you initialize executionService?