AnsweredAssumed Answered

Can I write a simple standalone atcitivi project which do not need to be deployed either on web server or application server?

Question asked by dharmeshyadav on Jun 1, 2018

I am trying to write a standalone activiti project. without spring boot or tomcat .

A pure standalone java project.

 

I created an activiti maven project. Creased a bpmn file.

I wrote a test java file - 

package test.main;

import org.activiti5.engine.ProcessEngine;
import org.activiti5.engine.ProcessEngineConfiguration;
import org.activiti5.engine.RepositoryService;
import org.activiti5.engine.RuntimeService;
import org.activiti5.engine.TaskService;
import org.activiti5.engine.runtime.ProcessInstance;
import org.activiti5.engine.task.Task;

public class MainTest {
public static void main(String[] args) {

ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
RepositoryService repositoryService=processEngine.getRepositoryService();
repositoryService.createDeployment().addClasspathResource("diagrams/TestProcess.bpmn").deploy();

RuntimeService runtimeService=processEngine.getRuntimeService();
ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("startProcess");

TaskService taskService=processEngine.getTaskService();
Task task=taskService.createTaskQuery().taskAssignee("PQR").singleResult();

System.out.println(task.getName());
}
}

 

It also got compiled successfully.

 

But when I run the standalone java application, it fails with NoClassDefFoundError: org/springframework/core/io/Resource.

 

If project was build successfully, then it must have resolved all the dependencies .

 

do I need to deliberately provide the dependencies, below is my pom file.

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.activiti.examples</groupId>
<artifactId>activiti-examples</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BPMN 2.0 with Activiti - Examples</name>
<properties>
<activiti-version>6.0.0</activiti-version>
</properties>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>${activiti-version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>${activiti-version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.168</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.USER_LIBRARY/Activiti Designer Extensions</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
</plugins>
</build>
</project>

Outcomes