AnsweredAssumed Answered

How to Create Stand alone Process Engine

Question asked by missordoni on Sep 28, 2017

Eclipse: Oxygen.1 (4.7.1)

H2: 1.3.176

Activiti: 6.0.0

I'm new in Activiti and I just want to run a process Not using the in-memory database, but switched to (createStandaloneProcessEngineConfiguration) inorder to the default standalone H2 database.

Regarding this, I have 2 questions:

 

1. What is the exact difference between createStandaloneProcessEngineConfiguration and createStandaloneInMemProcessEngineConfiguration for process engine configuration.

 

2. While I want to run a simple project, it throws some exception.

 

Sample Project:

public static void startBookOrder1() {
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration()
.buildProcessEngine();

RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
IdentityService identityService = processEngine.getIdentityService();
TaskService taskService = processEngine.getTaskService();

repositoryService.createDeployment()
.addClasspathResource("bookorder.bpmn20.xml")
.deploy();

List<Task> availableTaskList = taskService.createTaskQuery().taskName("Work on order").list();
for (Task task : availableTaskList) {
taskService.complete(task.getId());
}

Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("isbn", "123456");
identityService.setAuthenticatedUserId("kermit");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(
"bookorder", variableMap);
assertNotNull(processInstance.getId());
List<Task> taskList = taskService.createTaskQuery().taskName("Work on order").list();
assertEquals(1, taskList.size());
System.out.println("found task " + taskList.get(0).getName());
System.out.println("found task " );
}

Exceptions:

 

Exception in thread "main" org.activiti.engine.ActivitiException: no activiti tables in db. set <property name="databaseSchemaUpdate" to value="true" or value="create-drop" (use create-drop for testing only!) in bean processEngineConfiguration in activiti.cfg.xml for automatic schema creation
at org.activiti.engine.impl.db.DbSqlSession.dbSchemaCheckVersion(DbSqlSession.java:989)
at org.activiti.engine.impl.db.DbSqlSession.performSchemaOperationsProcessEngineBuild(DbSqlSession.java:1470)
at org.activiti.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:25)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:77)
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:427)
at BookOrderTest.startBookOrder1(BookOrderTest.java:33)
at BookOrderTest.main(BookOrderTest.java:26)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.h2.jdbc.JdbcSQLException: Table "ACT_GE_PROPERTY" not found; SQL statement:
select VALUE_ from ACT_GE_PROPERTY where NAME_ = 'schema.version' [42102-176]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
at org.h2.message.DbException.get(DbException.java:178)
at org.h2.message.DbException.get(DbException.java:154)
at org.h2.command.Parser.readTableOrView(Parser.java:5213)
at org.h2.command.Parser.readTableFilter(Parser.java:1220)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1859)
at org.h2.command.Parser.parseSelectSimple(Parser.java:1968)
at org.h2.command.Parser.parseSelectSub(Parser.java:1853)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1674)
at org.h2.command.Parser.parseSelect(Parser.java:1662)
at org.h2.command.Parser.parsePrepared(Parser.java:434)
at org.h2.command.Parser.parse(Parser.java:306)
at org.h2.command.Parser.parse(Parser.java:278)
at org.h2.command.Parser.prepareCommand(Parser.java:243)
at org.h2.engine.Session.prepareLocal(Session.java:442)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:265)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
at java.lang.Thread.run(Unknown Source)

### 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
### SQL: select VALUE_ from ACT_GE_PROPERTY where NAME_ = 'schema.version'
### Cause: org.h2.jdbc.JdbcSQLException: Table "ACT_GE_PROPERTY" not found; SQL statement:
select VALUE_ from ACT_GE_PROPERTY where NAME_ = 'schema.version' [42102-176]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
at org.h2.message.DbException.get(DbException.java:178)
at org.h2.message.DbException.get(DbException.java:154)
at org.h2.command.Parser.readTableOrView(Parser.java:5213)
at org.h2.command.Parser.readTableFilter(Parser.java:1220)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1859)
at org.h2.command.Parser.parseSelectSimple(Parser.java:1968)
at org.h2.command.Parser.parseSelectSub(Parser.java:1853)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1674)
at org.h2.command.Parser.parseSelect(Parser.java:1662)
at org.h2.command.Parser.parsePrepared(Parser.java:434)
at org.h2.command.Parser.parse(Parser.java:306)
at org.h2.command.Parser.parse(Parser.java:278)
at org.h2.command.Parser.prepareCommand(Parser.java:243)
at org.h2.engine.Session.prepareLocal(Session.java:442)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:265)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
at java.lang.Thread.run(Unknown Source)

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:62)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:57)
at org.activiti.engine.impl.db.DbSqlSession.getDbVersion(DbSqlSession.java:1011)
at org.activiti.engine.impl.db.DbSqlSession.dbSchemaCheckVersion(DbSqlSession.java:967)
... 10 more
Caused by: org.h2.jdbc.JdbcSQLException: Table "ACT_GE_PROPERTY" not found; SQL statement:
select VALUE_ from ACT_GE_PROPERTY where NAME_ = 'schema.version' [42102-176]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
at org.h2.message.DbException.get(DbException.java:178)
at org.h2.message.DbException.get(DbException.java:154)
at org.h2.command.Parser.readTableOrView(Parser.java:5213)
at org.h2.command.Parser.readTableFilter(Parser.java:1220)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1859)
at org.h2.command.Parser.parseSelectSimple(Parser.java:1968)
at org.h2.command.Parser.parseSelectSub(Parser.java:1853)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1674)
at org.h2.command.Parser.parseSelect(Parser.java:1662)
at org.h2.command.Parser.parsePrepared(Parser.java:434)
at org.h2.command.Parser.parse(Parser.java:306)
at org.h2.command.Parser.parse(Parser.java:278)
at org.h2.command.Parser.prepareCommand(Parser.java:243)
at org.h2.engine.Session.prepareLocal(Session.java:442)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:265)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
at java.lang.Thread.run(Unknown Source)

at org.h2.engine.SessionRemote.done(SessionRemote.java:567)
at org.h2.command.CommandRemote.prepare(CommandRemote.java:67)
at org.h2.command.CommandRemote.<init>(CommandRemote.java:46)
at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:439)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1109)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:74)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:264)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.datasource.pooled.PooledConnection.invoke(PooledConnection.java:245)
at com.sun.proxy.$Proxy2.prepareStatement(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:72)
at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:82)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:54)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:70)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
... 15 more

 

What I did for H2 database:

1. I copied the h2-1.3.176.jar file into activiti libreries folder.

2. I have created a file 'activiti.cfg.xml' in this direction of my project : /test/resources. it contains the below data:

activiti.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration" >
    <!-- Database configurations -->
    <property name="databaseType" value="h2" />
    <property name="jdbcUrl" value="jdbc:h2:tcp://localhost/activiti" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="sa" />
    <property name="databaseSchemaUpdate" value="create-drop" />
  </bean>
 
</beans>

 

I've attached the sample project for more information.

Thank you for any helping. 

Attachments

Outcomes