AnsweredAssumed Answered

Creating a Process Instance with Java

Question asked by zlatan316 on Jun 26, 2015
Latest reply on Jun 29, 2015 by zlatan316
Hi all,

I have a linux server setup with activiti that we use to create bpmn process via Activiti Explorer.
I am trying to write a class that will create an activiti process through code, and is runnable as a JAR on the server. Here is what i have so far:

   public static void spawnBPMNProcess() {
      System.out.println("Started spawnBPMNProcess()");
      ProcessEngine processEngine = ProcessEngineConfiguration
      RepositoryService repositoryService = processEngine.getRepositoryService();
      RuntimeService runtimeService = processEngine.getRuntimeService();
      IdentityService identityService = processEngine.getIdentityService();
      System.out.println("Referencing BPMN diagram to launch…");
      Map<String, Object> variableMap = new HashMap<String, Object>();
      variableMap.put("clientString", "test_ACP");
      System.out.println("Launching process…");
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("variableMap", variableMap);
      System.out.println("Process Definition ID: " + processInstance.getProcessDefinitionId());
      System.out.println("Activiti ID: " + processInstance.getActivityId());
      System.out.println("Launch complete!");

This code however gives me the below errors:
java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: org.h2.Driver
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.sql.SQLException: No suitable driver found for jdbc:h2:tcp://localhost/activiti
### The error may exist in org/activiti/db/mapping/entity/Property.xml
### The error may involve org.activiti.engine.impl.persistence.entity.PropertyEntity.selectDbSchemaVersion
### The error occurred while executing a query
### Cause: java.sql.SQLException: No suitable driver found for jdbc:h2:tcp://localhost/activiti

This seems to indicate I need to reference the database that exists on the server, how can i resolve this issue?

With Thanks.