org.camunda.bpm.engine.context - ENGINE-16004 Exception while closing command context: An exception occurred in the persistence layer. Please check the server logs for a detailed message and the entire exception stack trace.
org.camunda.bpm.engine.ProcessEngineException: An exception occurred in the persistence layer. Please check the server logs for a detailed message and the entire exception stack trace.
at org.camunda.bpm.engine.impl.util.ExceptionUtil.wrapPersistenceException(ExceptionUtil.java:263)
at org.camunda.bpm.engine.impl.util.ExceptionUtil.doWithExceptionWrapper(ExceptionUtil.java:257)
at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.executeSelectList(DbSqlSession.java:111)
at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.selectList(DbSqlSession.java:103)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectListWithRawParameter(DbEntityManager.java:182)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:174)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:170)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:159)
at org.camunda.bpm.engine.impl.persistence.entity.JobManager.findNextJobsToExecute(JobManager.java:238)
at org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:66)
at org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:44)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.CommandCounterInterceptor.execute(CommandCounterInterceptor.java:35)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.engine.impl.jobexecutor.SequentialJobAcquisitionRunnable.acquireJobs(SequentialJobAcquisitionRunnable.java:164)
at org.camunda.bpm.engine.impl.jobexecutor.SequentialJobAcquisitionRunnable.run(SequentialJobAcquisitionRunnable.java:80)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.h2.jdbc.JdbcSQLSyntaxErrorException: Values of types "BOOLEAN" and "INTEGER" are not comparable; SQL statement:
select RES.ID_,
RES.REV_,
RES.DUEDATE_,
RES.PROCESS_INSTANCE_ID_,
RES.EXCLUSIVE_
from ACT_RU_JOB RES
where (RES.RETRIES_ > 0)
and (
RES.DUEDATE_ is null or
RES.DUEDATE_ <= ?
)
and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?)
and RES.SUSPENSION_STATE_ = 1
and (
(
RES.EXCLUSIVE_ = 1
and not exists(
select J2.ID_ from ACT_RU_JOB J2
where J2.PROCESS_INSTANCE_ID_ = RES.PROCESS_INSTANCE_ID_ -- from the same proc. inst.
and (J2.EXCLUSIVE_ = 1) -- also exclusive
and (J2.LOCK_OWNER_ is not null and J2.LOCK_EXP_TIME_ >= ?) -- in progress
)
)
or
RES.EXCLUSIVE_ = 0
)
LIMIT ? OFFSET ? [90110-206]
And other similar errors. I’ve been searching for a resolution for a while now but I can’t find one. This seems relevant:
Hi,
I don’t have any advice or workarounds unfortunately, officially H2 is supported by Camunda but in version 1.4: Supported Environments | docs.camunda.org
I’ve been using it without problems in local development in that version.
As a workaround for your issue you could add a ProcessEnginePlugin to alter the database-specific SQL. For Spring (Boot) you can just add this ProcessEnginePlugin as a Component:
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin;
import org.camunda.bpm.engine.impl.db.sql.DbSqlSessionFactory;
import org.camunda.bpm.spring.boot.starter.configuration.Ordering;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Component
@Order(Ordering.DEFAULT_ORDER + 2)
public class H2SqlConfigurationProcessEnginePlugin implements ProcessEnginePlugin {
@Override
public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
DbSqlSessionFactory.databaseSpecificTrueConstant.put("h2", "true");
DbSqlSessionFactory.databaseSpecificFalseConstant.put("h2", "false");
DbSqlSessionFactory.databaseSpecificBitAnd2.put("h2", ",CAST(");
DbSqlSessionFactory.databaseSpecificBitAnd3.put("h2", " AS BIGINT))");
}
@Override
public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
// in this case only preInit is necessary
}
@Override
public void postProcessEngineBuild(ProcessEngine processEngine) {
// in this case only preInit is necessary
}
}
It is working perfectly fine with 1.4.200 but when I try to upgrade H2 to 2.1.210 I get the below exception
2022-04-19 12:29:16.677 [JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor]]org.camunda.bpm.engine.ProcessEngineException: An exception occurred in the persistence layer. Please check the server logs for a detailed message and the entire exception stack trace.
at org.camunda.bpm.engine.impl.util.ExceptionUtil.wrapPersistenceException(ExceptionUtil.java:263)
at org.camunda.bpm.engine.impl.util.ExceptionUtil.doWithExceptionWrapper(ExceptionUtil.java:257)
at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.executeSelectList(DbSqlSession.java:111)
at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.selectList(DbSqlSession.java:103)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectListWithRawParameter(DbEntityManager.java:182)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:174)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:170)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:159)
at org.camunda.bpm.engine.impl.persistence.entity.JobManager.findNextJobsToExecute(JobManager.java:238)
at org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:66)
at org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:44)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:72)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.CommandCounterInterceptor.execute(CommandCounterInterceptor.java:35)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.engine.impl.jobexecutor.SequentialJobAcquisitionRunnable.acquireJobs(SequentialJobAcquisitionRunnable.java:164)
at org.camunda.bpm.engine.impl.jobexecutor.SequentialJobAcquisitionRunnable.run(SequentialJobAcquisitionRunnable.java:80)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "select RES.ID_,\000a RES.REV_,\000a RES.DUEDATE_,\000a RES.PROCESS_INSTANCE_ID_,\000a RES.EXCLUSIVE_\000a \000a from ACT_RU_JOB RES\000a\000a where (RES.RETRIES_ > 0)\000a and (\000a \000a RES.DUEDATE_ is null or\000a \000a RES.DUEDATE_ <= ?\000a )\000a and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?)\000a and RES.SUSPENSION_STATE_ = 1\000a\000a \000a\000a \000a \000a\000a and ( \000a ( \000a RES.EXCLUSIVE_ = true\000a and not exists(\000a select J2.ID_ from ACT_RU_JOB J2\000a where J2.PROCESS_INSTANCE_ID_ = RES.PROCESS_INSTANCE_ID_ from the same proc. inst.\000a and (J2.EXCLUSIVE_ = true) -- also exclusive\000a and (J2.LOCK_OWNER_ is not null and J2.LOCK_EXP_TIME_ >= ?) -- in progress\000a )\000a )\000a or\000a \000a RES.EXCLUSIVE_ = false\000a \000a )\000a\000a \000a\000a \000a [*]LIMIT ? OFFSET ?"; SQL statement:
select RES.ID_,
RES.REV_,
RES.DUEDATE_,
RES.PROCESS_INSTANCE_ID_,
RES.EXCLUSIVE_
from ACT_RU_JOB RES
where (RES.RETRIES_ > 0)
and (
RES.DUEDATE_ is null or
RES.DUEDATE_ <= ?
)
and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?)
and RES.SUSPENSION_STATE_ = 1
and (
(
RES.EXCLUSIVE_ = true
and not exists(
select J2.ID_ from ACT_RU_JOB J2
where J2.PROCESS_INSTANCE_ID_ = RES.PROCESS_INSTANCE_ID_ -- from the same proc. inst.
and (J2.EXCLUSIVE_ = true) -- also exclusive
and (J2.LOCK_OWNER_ is not null and J2.LOCK_EXP_TIME_ >= ?) -- in progress
)
)
or
RES.EXCLUSIVE_ = false
)
LIMIT ? OFFSET ? [42000-210]
### The error may exist in org/camunda/bpm/engine/impl/mapping/entity/Job.xml
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
### The error occurred while executing a query