Creating a Process Instance with Java

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2015 11:49 AM
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:
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.
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()"); Authentication.setAuthenticatedUserId("admin"); ProcessEngine processEngine = ProcessEngineConfiguration .createStandaloneProcessEngineConfiguration() .buildProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService(); RuntimeService runtimeService = processEngine.getRuntimeService(); IdentityService identityService = processEngine.getIdentityService(); System.out.println("Referencing BPMN diagram to launch…"); repositoryService.createDeployment() .addClasspathResource("liveprocess.bpmn20.xml") .deploy(); Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("clientString", "test_ACP"); identityService.setAuthenticatedUserId("admin"); 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.
Labels:
- Labels:
-
Archive
4 REPLIES 4

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2015 05:32 PM
Hi,
Seems that your code is missing JDBC driver jar for H2 database.
Do you plan to run the code inside the Activiti Explorer webapp or as a separate Java application?
Seems that your code is missing JDBC driver jar for H2 database.
Do you plan to run the code inside the Activiti Explorer webapp or as a separate Java application?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 05:07 AM
Hi, I plan to initially create the process from a Java app, then manage it in the Activiti Explorer UI. Which JAR would I need to include along with my other 3rd party jars?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2015 04:14 PM
As Bassam says, from your exception it seems the H2 driver is missing, dependency is here: http://mvnrepository.com/artifact/com.h2database/h2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2015 10:17 AM
Thanks, this was a dependancy missing from my classpath. I actually wanted to use mysql anyway so I added the steps specified inthe Activiti in action book and it worked fine.
