0
votes

I am trying to make a simple Hello world application using Activiti eclipse BPMN Designer 5.9. I made a activiti project in eclipse and added my check.bpmn diagram to src/main/resources folder and my .java to src/test/java and activiti.cfg.xml files to the src/test/resources folder. The application is just suppose to show alert "Hello" to the console, but I cannot seem to get it to do this. Below if all the files that I am using to run the application. I don't know what i am missing.I have installed Activiti Eclipse BPMN 2.0 designer.

UPDATE:

i have added jar files enter image description here

Error:

enter image description here POM.xml:

<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>5.8</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</artifactId>
      <version>1.7.5</version>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <version>1.2.132</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
    </dependency>
  </dependencies>
     <repositories>
    <repository>
      <id>Activiti</id>
      <url>http://maven.alfresco.com/nexus/content/repositories/activiti</url>
       </repository>
     </repositories>
     <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>

Check.bpmn:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="process1" name="process1">
    <startEvent id="startevent1" name="Start"></startEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript">
      <script><![CDATA[alert("hello");]]></script>
    </scriptTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" name="" sourceRef="scripttask1" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_process1">
    <bpmndi:BPMNPlane bpmnElement="process1" id="BPMNPlane_process1">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="200" y="160"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55" width="105" x="280" y="150"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="440" y="160"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="235" y="177"></omgdi:waypoint>
        <omgdi:waypoint x="280" y="177"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="385" y="177"></omgdi:waypoint>
        <omgdi:waypoint x="440" y="177"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

ProcessTestProcess1.java

package org.activiti.designer.test;

import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.Map;
import java.io.FileInputStream;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.test.ActivitiRule;
import org.junit.Rule;
import org.junit.Test;

public class ProcessTestProcess1 {

    private String filename = "C:\Users\User\workspace\Proj\src\main\resources\diagrams\Check.bpmn";

    @Rule
    public ActivitiRule activitiRule = new ActivitiRule();

    @Test
    public void startProcess() throws Exception {
        RepositoryService repositoryService = activitiRule.getRepositoryService();
        repositoryService.createDeployment().addInputStream("process1.bpmn20.xml",
                new FileInputStream(filename)).deploy();
        RuntimeService runtimeService = activitiRule.getRuntimeService();
        Map<String, Object> variableMap = new HashMap<String, Object>();
        variableMap.put("name", "Activiti");
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
        assertNotNull(processInstance.getId());
        System.out.println("id " + processInstance.getId() + " "
                + processInstance.getProcessDefinitionId());
    }
}

Error:

Description Resource    Path    Location    Type
The import org.activiti.engine cannot be resolved   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 9  Java Problem
The import org.activiti.engine cannot be resolved   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 10 Java Problem
The import org.activiti.engine cannot be resolved   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 11 Java Problem
The import org.activiti.engine cannot be resolved   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 12 Java Problem
The import org.activiti cannot be resolved  Main.java   /helloworld/src/main/java   line 1  Java Problem
The import org.activiti cannot be resolved  Main.java   /helloworld/src/main/java   line 2  Java Problem
The import org.activiti cannot be resolved  Main.java   /helloworld/src/main/java   line 3  Java Problem
RuntimeService cannot be resolved to a type ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 28 Java Problem
RepositoryService cannot be resolved to a type  ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 25 Java Problem
ProcessService cannot be resolved to a type Main.java   /helloworld/src/main/java   line 13 Java Problem
ProcessInstance cannot be resolved to a type    ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 31 Java Problem
ProcessEngine cannot be resolved to a type  Main.java   /helloworld/src/main/java   line 10 Java Problem
Invalid escape sequence (valid ones are  \b  \t  \n  \f  \r  \"  \'  \\ )   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 18 Java Problem
DbProcessEngineBuilder cannot be resolved to a type Main.java   /helloworld/src/main/java   line 10 Java Problem
ActivitiRule cannot be resolved to a type   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 21 Java Problem
ActivitiRule cannot be resolved to a type   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 21 Java Problem
ActivitiRule cannot be resolved to a type   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 25 Java Problem
ActivitiRule cannot be resolved to a type   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 28 Java Problem
3

3 Answers

2
votes

The error

Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \ )

tells you your String is invalid.

private String filename = "C:\Users\User\workspace\Proj\src\main\resources\diagrams\Check.bpmn";

should be escaped

private String filename = "C:\\Users\\User etc...";
1
votes

You have to convert project to maven project. After that you will see "Maven Dependencies" in your project and class path.

To convert try right button on project name -> context menu -> Configure -> Convert to Maven project.

enter image description here

enter image description here

0
votes

Check maven dependencies in you project structure. check if activiti-engine-{activiti-version}.jar is available or not.