AnsweredAssumed Answered

Problems with executing the 10 minute tutorial

Question asked by d00d on Oct 31, 2014
Latest reply on Oct 31, 2014 by jbarrez
I am new to activiti and wanted to start with the 10 minutes tutorial in eclipse. I installed the activiti plugin and created a new activiti project with a new class containing the code of the tutorial


public class TenMinuteTutorial {
 
  public static void main(String[] args) {
   
    // Create Activiti process engine
    ProcessEngine processEngine = ProcessEngineConfiguration
      .createStandaloneProcessEngineConfiguration()
      .buildProcessEngine();
   
    // Get Activiti services
    RepositoryService repositoryService = processEngine.getRepositoryService();
    RuntimeService runtimeService = processEngine.getRuntimeService();
   
    // Deploy the process definition
    repositoryService.createDeployment()
      .addClasspathResource("FinancialReportProcess.bpmn20.xml")
      .deploy();
   
    // Start a process instance
    String procId = runtimeService.startProcessInstanceByKey("financialReport").getId();
   
    // Get the first task
    TaskService taskService = processEngine.getTaskService();
    List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("accountancy").list();
    for (Task task : tasks) {
      System.out.println("Following task is available for accountancy group: " + task.getName());
     
      // claim it
      taskService.claim(task.getId(), "fozzie");
    }
   
    // Verify Fozzie can now retrieve the task
    tasks = taskService.createTaskQuery().taskAssignee("fozzie").list();
    for (Task task : tasks) {
      System.out.println("Task for fozzie: " + task.getName());
     
      // Complete the task
      taskService.complete(task.getId());
    }
   
    System.out.println("Number of tasks for fozzie: "
            + taskService.createTaskQuery().taskAssignee("fozzie").count());
   
    // Retrieve and claim the second task
    tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
    for (Task task : tasks) {
      System.out.println("Following task is available for accountancy group: " + task.getName());
      taskService.claim(task.getId(), "kermit");
    }
   
    // Completing the second task ends the process
    for (Task task : tasks) {
      taskService.complete(task.getId());
    }
   
    // verify that the process is actually finished
    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance =
      historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
    System.out.println("Process instance end time: " + historicProcessInstance.getEndTime());
  }

}


I put the FinancialReportProcess.bpmn20.xml into the same folder as the java class. I also added all the jars that came with the activiti 5.6.14 package to my projects workspace.

After the first start i experienced some "classDefNotFound" errors. I had to manually add .jars for ibatis-core (ibatis-core-3.0.jar), joda-time, h2 and apache commons. But i still get errors and cant execute this first simple 10 minute tutorial script because of the following error message:

<quote>
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/ibatis/type/TypeReference
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$100(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:191)
   at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:91)
   at org.apache.ibatis.io.Resources.classForName(Resources.java:229)
   at org.apache.ibatis.builder.xml.XMLConfigBuilder.typeAliasesElement(XMLConfigBuilder.java:81)
   at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:61)
   at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:55)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.parseMybatisConfiguration(ProcessEngineConfigurationImpl.java:738)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initMybatisConfiguration(ProcessEngineConfigurationImpl.java:721)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initSqlSessionFactory(ProcessEngineConfigurationImpl.java:702)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:436)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:408)
   at TenMinuteTutorial.main(TenMinuteTutorial.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.ibatis.type.TypeReference
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   … 24 more
</quote>

I just don't get whats wrong and why i needed to add certain packages that are not being mentioned in the tutorial. Any ideas?

Outcomes