AnsweredAssumed Answered

Problem with events

Question asked by swsw1 on Oct 24, 2014
Latest reply on Nov 7, 2014 by swsw1
I have got a Vaadin application with a Button which throws events of type ClickEvent. Although I imported all activity-jars, there is always a NullPointerException - I cannot create the ProcessEngine.

The exception reads as follows:


Servlet.service() for servlet [Vaadin Application] in context with path [/Vaadin] threw exception [java.lang.NullPointerException] with root cause
java.lang.NullPointerException
   at com.example.vaadin.VaadinApplication.init(VaadinApplication.java:42)
   at com.vaadin.Application.start(Application.java:551)
   at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1219)
   at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


Moreover, my original plan has been to controll trigger the process by the ClickEvents thrown by my button. I defined an intermediate catch event in my bpmn.xml, I added an event listener to my runtimeService-object, my idea was to give the signal event as id the String "ClickEvent", because the event thrown by my button is of type ClickEvent, and the method buttonClick ought to be responsible of throwing the intermediateCatchEvent, which is also there in the .xml-file, but I do not know how tho achieve this.

Here is my xml-file:


<?xml version="1.0" encoding="UTF-8" ?>

<definitions id="definitions"
  targetNamespace="http://activiti.org/bpmn20"
  xmlns:activiti="http://activiti.org/bpmn"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">

<process id="catchSignal">

<signal id="ClickEvent" name="event" />
              
         <intermediateCatchEvent id="catchSignalEvent" name="OnAlert">
                      <!– signal event definition –>
                        <signalEventDefinition signalRef="alertSignal" />
         </intermediateCatchEvent>
           
        </process>
</definitions>


…and this is my Vaadin code:


package com.example.vaadin;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.activiti.engine.task.Task;
import org.activiti.engine.HistoryService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.Execution;
import org.activiti.engine.runtime.ProcessInstance;
import org.apache.commons.logging.Log;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

/**
* Main application class.
*/
public class VaadinApplication extends Application implements ActivitiEventListener{

   RuntimeService runtimeService = null;
   
   
   @Override
   public void init(){

      //Meine ProcessEngine.
      ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
      
      //The workflow will have to be concretised in the *.bpmn20.xml - file.
      RepositoryService repositoryService = processEngine.getRepositoryService();
      RuntimeService runtimeService = processEngine.getRuntimeService();
          runtimeService.addEventListener(this);
      
      repositoryService.createDeployment()
        .addClasspathResource("bpmn/EventTest.bpmn20.xml")
        .deploy();

      
      Window mainWindow = new Window("Vaadin Application");
      Button but = new Button("Event");
      but.addListener(new ClickListener(){

         @Override
         public void buttonClick(ClickEvent event) {
              
         }
         
      });
      mainWindow.addComponent(but);
      setMainWindow(mainWindow);
      
      
   }


   @Override
   public boolean isFailOnException() {
      // TODO Auto-generated method stub
      return false;
   }


   @Override
   public void onEvent(ActivitiEvent ae) {
      // TODO Auto-generated method stub
      
   }

   
}



Outcomes