Problem with events

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2014 04:58 AM
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:
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:
…and this is my Vaadin code:
The exception reads as follows:
Servlet.service() for servlet [Vaadin Application] in context with path [/Vaadin] threw exception [java.lang.NullPointerException] with root causejava.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 } }
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2014 07:03 AM
So you mean that ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); gives a NPE?
By default, Activiti will look for an activiti.cfg.xml file on the classpath. Do you have that?
By default, Activiti will look for an activiti.cfg.xml file on the classpath. Do you have that?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2014 03:42 AM
Thank You! Being a noob, I forgot adding the cfg.xml to the classpath. Now, there is still a classloader problem, but the creation of the engine is working now.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2014 10:04 AM
http://forums.activiti.org/
swsw 666sdf76
I have started programming a new application where I also want to create my process engine based on a activiti.cfg.xml-file (and once again I take the one that is there in the documentation), and again, I am running into a nullpointer exception, and everything I tried in order to add the cfg.xml-file to the classpath did not succeed.
On running my code on Tomcat, I have a NullPointerException for my "processEngine" remains null.
…
<code>ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();</code>
…
So what do I have to do to add the activiti.cfg.xml to my classpath?
Here is my activiti.cfg.xml:
<code>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
<property name="mailServerHost" value="mail.my-corp.com" />
<property name="mailServerPort" value="5025" />
</bean>
</beans>
</code>
swsw 666sdf76
I have started programming a new application where I also want to create my process engine based on a activiti.cfg.xml-file (and once again I take the one that is there in the documentation), and again, I am running into a nullpointer exception, and everything I tried in order to add the cfg.xml-file to the classpath did not succeed.
On running my code on Tomcat, I have a NullPointerException for my "processEngine" remains null.
…
<code>ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();</code>
…
So what do I have to do to add the activiti.cfg.xml to my classpath?
Here is my activiti.cfg.xml:
<code>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
<property name="mailServerHost" value="mail.my-corp.com" />
<property name="mailServerPort" value="5025" />
</bean>
</beans>
</code>
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2014 06:44 AM
Just put it on the tomcat classpath: /lib or (better) WEB-INF/lib of the war

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2014 12:13 PM
Thank You, now it is working, after all 🙂
