Details
Description
Application creates a process engine won't start because of a configuration issue of history level.
Reproduction:
- Database tables created by bundled postgres scripts (org\activiti\db\create\activiti.postgres.create.*.sql).
- There is no record in act_ge_property with name_ = 'historyLevel'.
- Developing application with the following configuration:
final ProcessEngine processEngine = ProcessEngineConfiguration .createStandaloneProcessEngineConfiguration() .setHistory(ProcessEngineConfiguration.HISTORY_ACTIVITY) .setDatabaseType("postgres") .setDataSource(dataSource).buildProcessEngine();
- On application start the following exception came:
[#|2011-09-05T18:53:45.011+0200|SEVERE|glassfish3.1.1|org.activiti.engine.impl.interceptor.CommandContext|_ThreadID=17;_ThreadName=Thread-2;|Error while closing command context org.activiti.engine.ActivitiException: Activiti database problem: no historyLevel property specified at org.activiti.engine.impl.db.DbSqlSession.dbSchemaCheckVersion(DbSqlSession.java:510) at org.activiti.engine.impl.db.DbSqlSession.performSchemaOperationsProcessEngineBuild(DbSqlSession.java:882) at org.activiti.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:25) at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42) at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) at org.activiti.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:77) at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:270) at activiti.test.impl.Activator.start(Activator.java:28)
Supposed location of the bug:
The root of this problem might be in org.activiti.engine.impl.db.DbSqlSession.dbSchemaCheckVersion() method, on lines 492-511:
Integer configuredHistoryLevel = Context.getProcessEngineConfiguration().getHistoryLevel();
PropertyEntity historyLevelProperty = selectById(PropertyEntity.class, "historyLevel");
if (historyLevelProperty==null) {
if (errorMessage==null) {
errorMessage = "";
}
errorMessage += "no historyLevel property specified";
} else {
Integer databaseHistoryLevel = new Integer(historyLevelProperty.getValue());
if (!configuredHistoryLevel.equals(databaseHistoryLevel)) {
if (errorMessage==null) {
errorMessage = "";
}
errorMessage += "historyLevel mismatch: configuration says "+configuredHistoryLevel+" and database says "+databaseHistoryLevel;
}
}
if (errorMessage!=null) {
throw new ActivitiException("Activiti database problem: "+errorMessage);
}
It always checks the 'historyLevel' property in the database and if it is not there the before mentioned exception will be thrown, whether or not the history level property of ProcessEngineConfigurationImpl is set.
Local quickfix:
Quick (and dirty) solution was to insert the ("historyLevel";"1";1) record directly into the act_ge_property table of the database. It is dirty because the lines of dbSchemaCheckVersion() above checks if the property value is same in the config and in the db. So if i reconfigure the ProcessEngine, i will have to alter the data in the db manually too.
Possible solution:
I assume the modification of the quoted lines of the source code of the activiti engine is required to solve this issue.
Issue Links
- relates to
-
ACT-1333
Fix upgrade script
-
Could you make the subject more specific. It is very generic now