Execute
// ensure that at least one external for topic "bar" exists // ensure that the corresponding process instance has at least one variable ProcessEngine engine = rule.getProcessEngine(); engine.getExternalTaskService().fetchAndLock(10, "foo") .topic("bar", 1000L) .variables(new String[]{}) .execute();
Fails with the following exception:
org.camunda.bpm.engine.ProcessEngineException: Process engine persistence exception at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.rethrow(CommandInvocationContext.java:148) at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:173) at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:113) at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66) at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) at org.camunda.bpm.engine.impl.externaltask.ExternalTaskQueryTopicBuilderImpl.execute(ExternalTaskQueryTopicBuilderImpl.java:56) at org.camunda.bpm.unittest.SimpleTestCase.foo(SimpleTestCase.java:105) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) at org.camunda.bpm.engine.test.ProcessEngineRule$1.evaluate(ProcessEngineRule.java:165) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "SELECT RES.*, ( CASE WHEN RES.TASK_ID_ IS NOT NULL AND RES.EXECUTION_ID_ IS NOT NULL THEN EXECUTION.ACT_INST_ID_ WHEN RES.CASE_EXECUTION_ID_ IS NOT NULL THEN RES.CASE_EXECUTION_ID_ WHEN EXECUTION.PARENT_ID_ IS NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN EXECUTION.ID_ WHEN EXECUTION.IS_SCOPE_ = 1 AND EXECUTION.PARENT_ID_ IS NOT NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN PARENT_EXECUTION.ACT_INST_ID_ ELSE EXECUTION.ACT_INST_ID_ END ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ IS NULL AND NAME_ IN "; erwartet "(" Syntax error in SQL statement "SELECT RES.*, ( CASE WHEN RES.TASK_ID_ IS NOT NULL AND RES.EXECUTION_ID_ IS NOT NULL THEN EXECUTION.ACT_INST_ID_ WHEN RES.CASE_EXECUTION_ID_ IS NOT NULL THEN RES.CASE_EXECUTION_ID_ WHEN EXECUTION.PARENT_ID_ IS NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN EXECUTION.ID_ WHEN EXECUTION.IS_SCOPE_ = 1 AND EXECUTION.PARENT_ID_ IS NOT NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN PARENT_EXECUTION.ACT_INST_ID_ ELSE EXECUTION.ACT_INST_ID_ END ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ IS NULL AND NAME_ IN "; expected "("; SQL statement: SELECT RES.*, ( case when RES.TASK_ID_ is not null and RES.EXECUTION_ID_ is not null then EXECUTION.ACT_INST_ID_ when RES.CASE_EXECUTION_ID_ is not null then RES.CASE_EXECUTION_ID_ when EXECUTION.PARENT_ID_ is null and RES.IS_CONCURRENT_LOCAL_ = 0 then EXECUTION.ID_ when EXECUTION.IS_SCOPE_ = 1 and EXECUTION.PARENT_ID_ is not null and RES.IS_CONCURRENT_LOCAL_ = 0 then PARENT_EXECUTION.ACT_INST_ID_ else EXECUTION.ACT_INST_ID_ end ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ is null AND NAME_ IN [42001-168] ### The error may exist in org/camunda/bpm/engine/impl/mapping/entity/VariableInstance.xml ### The error may involve org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.selectVariablesByExecutionId ### The error occurred while executing a query ### SQL: SELECT RES.*, ( case when RES.TASK_ID_ is not null and RES.EXECUTION_ID_ is not null then EXECUTION.ACT_INST_ID_ when RES.CASE_EXECUTION_ID_ is not null then RES.CASE_EXECUTION_ID_ when EXECUTION.PARENT_ID_ is null and RES.IS_CONCURRENT_LOCAL_ = 0 then EXECUTION.ID_ when EXECUTION.IS_SCOPE_ = 1 and EXECUTION.PARENT_ID_ is not null and RES.IS_CONCURRENT_LOCAL_ = 0 then PARENT_EXECUTION.ACT_INST_ID_ else EXECUTION.ACT_INST_ID_ end ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ is null AND NAME_ IN ### Cause: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "SELECT RES.*, ( CASE WHEN RES.TASK_ID_ IS NOT NULL AND RES.EXECUTION_ID_ IS NOT NULL THEN EXECUTION.ACT_INST_ID_ WHEN RES.CASE_EXECUTION_ID_ IS NOT NULL THEN RES.CASE_EXECUTION_ID_ WHEN EXECUTION.PARENT_ID_ IS NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN EXECUTION.ID_ WHEN EXECUTION.IS_SCOPE_ = 1 AND EXECUTION.PARENT_ID_ IS NOT NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN PARENT_EXECUTION.ACT_INST_ID_ ELSE EXECUTION.ACT_INST_ID_ END ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ IS NULL AND NAME_ IN "; erwartet "(" Syntax error in SQL statement "SELECT RES.*, ( CASE WHEN RES.TASK_ID_ IS NOT NULL AND RES.EXECUTION_ID_ IS NOT NULL THEN EXECUTION.ACT_INST_ID_ WHEN RES.CASE_EXECUTION_ID_ IS NOT NULL THEN RES.CASE_EXECUTION_ID_ WHEN EXECUTION.PARENT_ID_ IS NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN EXECUTION.ID_ WHEN EXECUTION.IS_SCOPE_ = 1 AND EXECUTION.PARENT_ID_ IS NOT NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN PARENT_EXECUTION.ACT_INST_ID_ ELSE EXECUTION.ACT_INST_ID_ END ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ IS NULL AND NAME_ IN "; expected "("; SQL statement: SELECT RES.*, ( case when RES.TASK_ID_ is not null and RES.EXECUTION_ID_ is not null then EXECUTION.ACT_INST_ID_ when RES.CASE_EXECUTION_ID_ is not null then RES.CASE_EXECUTION_ID_ when EXECUTION.PARENT_ID_ is null and RES.IS_CONCURRENT_LOCAL_ = 0 then EXECUTION.ID_ when EXECUTION.IS_SCOPE_ = 1 and EXECUTION.PARENT_ID_ is not null and RES.IS_CONCURRENT_LOCAL_ = 0 then PARENT_EXECUTION.ACT_INST_ID_ else EXECUTION.ACT_INST_ID_ end ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ is null AND NAME_ IN [42001-168] at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.selectList(DbSqlSession.java:95) at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectListWithRawParameter(DbEntityManager.java:173) at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:165) at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:161) at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.selectList(DbEntityManager.java:145) at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceManager.findVariableInstancesByExecutionIdAndVariableNames(VariableInstanceManager.java:53) at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.provideVariables(ExecutionEntity.java:1233) at org.camunda.bpm.engine.impl.core.variable.scope.VariableStore.getVariablesMap(VariableStore.java:89) at org.camunda.bpm.engine.impl.core.variable.scope.VariableStore.getVariables(VariableStore.java:111) at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.getVariableInstancesLocal(AbstractVariableScope.java:189) at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.collectVariables(AbstractVariableScope.java:98) at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.collectVariables(AbstractVariableScope.java:109) at org.camunda.bpm.engine.impl.externaltask.LockedExternalTaskImpl.fromEntity(LockedExternalTaskImpl.java:147) at org.camunda.bpm.engine.impl.cmd.FetchExternalTasksCmd.execute(FetchExternalTasksCmd.java:75) at org.camunda.bpm.engine.impl.cmd.FetchExternalTasksCmd.execute(FetchExternalTasksCmd.java:40) at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104) ... 30 more Caused by: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "SELECT RES.*, ( CASE WHEN RES.TASK_ID_ IS NOT NULL AND RES.EXECUTION_ID_ IS NOT NULL THEN EXECUTION.ACT_INST_ID_ WHEN RES.CASE_EXECUTION_ID_ IS NOT NULL THEN RES.CASE_EXECUTION_ID_ WHEN EXECUTION.PARENT_ID_ IS NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN EXECUTION.ID_ WHEN EXECUTION.IS_SCOPE_ = 1 AND EXECUTION.PARENT_ID_ IS NOT NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN PARENT_EXECUTION.ACT_INST_ID_ ELSE EXECUTION.ACT_INST_ID_ END ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ IS NULL AND NAME_ IN "; erwartet "(" Syntax error in SQL statement "SELECT RES.*, ( CASE WHEN RES.TASK_ID_ IS NOT NULL AND RES.EXECUTION_ID_ IS NOT NULL THEN EXECUTION.ACT_INST_ID_ WHEN RES.CASE_EXECUTION_ID_ IS NOT NULL THEN RES.CASE_EXECUTION_ID_ WHEN EXECUTION.PARENT_ID_ IS NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN EXECUTION.ID_ WHEN EXECUTION.IS_SCOPE_ = 1 AND EXECUTION.PARENT_ID_ IS NOT NULL AND RES.IS_CONCURRENT_LOCAL_ = 0 THEN PARENT_EXECUTION.ACT_INST_ID_ ELSE EXECUTION.ACT_INST_ID_ END ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ IS NULL AND NAME_ IN "; expected "("; SQL statement: SELECT RES.*, ( case when RES.TASK_ID_ is not null and RES.EXECUTION_ID_ is not null then EXECUTION.ACT_INST_ID_ when RES.CASE_EXECUTION_ID_ is not null then RES.CASE_EXECUTION_ID_ when EXECUTION.PARENT_ID_ is null and RES.IS_CONCURRENT_LOCAL_ = 0 then EXECUTION.ID_ when EXECUTION.IS_SCOPE_ = 1 and EXECUTION.PARENT_ID_ is not null and RES.IS_CONCURRENT_LOCAL_ = 0 then PARENT_EXECUTION.ACT_INST_ID_ else EXECUTION.ACT_INST_ID_ end ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ is null AND NAME_ IN [42001-168] at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) at org.h2.message.DbException.get(DbException.java:169) at org.h2.message.DbException.getSyntaxError(DbException.java:194) at org.h2.command.Parser.getSyntaxError(Parser.java:491) at org.h2.command.Parser.read(Parser.java:2798) at org.h2.command.Parser.readCondition(Parser.java:1916) at org.h2.command.Parser.readAnd(Parser.java:1854) at org.h2.command.Parser.readExpression(Parser.java:1844) at org.h2.command.Parser.parseSelectSimple(Parser.java:1801) at org.h2.command.Parser.parseSelectSub(Parser.java:1684) at org.h2.command.Parser.parseSelectUnion(Parser.java:1527) at org.h2.command.Parser.parseSelect(Parser.java:1515) at org.h2.command.Parser.parsePrepared(Parser.java:405) at org.h2.command.Parser.parse(Parser.java:279) at org.h2.command.Parser.parse(Parser.java:255) at org.h2.command.Parser.prepareCommand(Parser.java:217) at org.h2.engine.Session.prepareLocal(Session.java:415) at org.h2.engine.Session.prepareCommand(Session.java:364) 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.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.ibatis.datasource.pooled.PooledConnection.invoke(PooledConnection.java:245) at com.sun.proxy.$Proxy10.prepareStatement(Unknown Source) at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:87) at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88) at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59) at org.apache.ibatis.executor.BatchExecutor.doQuery(BatchExecutor.java:91) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ... 48 more
This is a regression starting with 7.8.1 and 7.7.6.
Note that the root cause is the SQL statement for when a subset of variables is selected for an execution. The statement may be executed in the context of various other APIs as well.