cancel
Showing results for 
Search instead for 
Did you mean: 

Service Task could not be instantiated followed by a Boundary Timer Event on a User Task

dinesh_babu_p
Champ in-the-making
Champ in-the-making
Platform
1) Activiti Eclipse Designer 5.14 plugin
2) Activiti 5.17 jars on the ClassPath
3) DB2 database
4) JDK1.8
5) Custom Web Application using Spring and apache-cxf REST service through JSON input

My requirement is as follows,
1) When a process is started it will come to a UserTask (Handle Request) where approver has to perform an action.
2) There are two timers (Boundary Timer Event) on the UserTask (Handle Request).
i) Reminder Notification timer (notificationTimer) for the task to be completed to approver through mail task
II) Auto decision timer (autoDecisionTimer) which has to cancel the approval task and move further in the process flow to ServiceTask

Problem is,
Both the timers working fine if i dont have ServiceTask block but however if i have ServiceTask next to auto decision timer (autoDecisionTimer) only the (notificationTimer) is working fine and the (autoDecisionTimer) is failing.
It seems like it is giving RANDOM ERRORS, very few times it working fine. The scenarios are as follows,

Following are the observations from the ACT_RU_JOB table ,
SCENARIO 1:
REV =  7 and Exception_MSG_ =  couldn't instantiate class com.ms.msviz.activiti.workflow.servicetask.SrvcTask
This is class in ServiceTask which implements JavaDelegate
SCENARIO 2:
LOCK_EXP_TIME_ has some time and LOCK_OWNER_ has some random alphabets
SCENARIO 3:
Everything is working fine without any issues.

I have attached my process file and configuration file along with this issue, please find the attachments and please help us to resolve this issue, unable to even predict the result every time while running the process
10 REPLIES 10

dinesh_babu_p
Champ in-the-making
Champ in-the-making
Really got stuck here, seeking for the help. Almost provided all the information regarding the issue. I am new to Activiti ad unable to write test cases which involves Boundary Timer. please help me in resolving this timer issue. This is the biggest ShowStopper in learning the Boundary Timer Event which involves CancelActivity="true" followed by invoking a Java Class through listeners.

Kindly, provide us inputs to proceed further. Eagerly waiting for a response to solve this issue.

Appreciate your time,
Dinesh

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Dinesh,

Did you add com.ms.msviz.activiti.workflow.servicetask.SrvcTask to the classpath?

Regards
Martin

dinesh_babu_p
Champ in-the-making
Champ in-the-making
Hi Martin,
All the classes are added to the classpath. Whenever I invoke that class without timer it is able to pick up the class perfectly.
Exception arises only when it has to pick up after the timer which has "cancelActivity = true"

Regards,
Dinesh

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Dinesh.

Create jUnit test according to
https://forums.activiti.org/content/sticky-how-write-unit-test

How to do that:
org.activiti.engine.test.bpmn.event.timer.BoundaryTimerEventTest
in the activiti source code.

Regards
Martin

dinesh_babu_p
Champ in-the-making
Champ in-the-making
Hi Martin,

I have written, the test cases, the test case is passing however I am getting following exception in eclipse console.

14:57:17.707 [pool-1-thread-2] DEBUG o.a.engine.impl.db.DbSqlSession - executing: delete JobEntity [id=9]
14:57:17.707 [pool-1-thread-2] DEBUG o.a.e.i.p.e.JobEntity.deleteTimer - ==>  Preparing: delete from ACT_RU_JOB where ID_ = ? and REV_ = ?
14:57:17.707 [pool-1-thread-2] DEBUG o.a.e.i.p.e.JobEntity.deleteTimer - ==> Parameters: 9(String), 2(Integer)
14:57:17.707 [pool-1-thread-2] DEBUG o.a.e.i.p.e.JobEntity.deleteTimer - <==    Updates: 0
14:57:17.716 [pool-1-thread-2] DEBUG o.a.e.i.interceptor.CommandContext - Optimistic locking exception : org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=9] was updated by another transaction concurrently
14:57:17.716 [pool-1-thread-2] DEBUG o.a.e.i.c.s.StandaloneMybatisTransactionContext - firing event rolling back…
14:57:17.716 [pool-1-thread-2] DEBUG o.a.e.i.c.s.StandaloneMybatisTransactionContext - rolling back ibatis sql session…
14:57:17.716 [pool-1-thread-2] DEBUG o.a.i.t.jdbc.JdbcTransaction - Rolling back JDBC Connection [conn2: url=jdbc:h2:mem:activiti user=SA]
14:57:17.717 [pool-1-thread-2] DEBUG o.a.e.i.c.s.StandaloneMybatisTransactionContext - firing event rolled back…
14:57:17.726 [pool-1-thread-2] DEBUG o.a.e.i.interceptor.LogInterceptor -


14:57:17.824 [pool-1-thread-2] ERROR o.a.e.i.j.ExecuteJobsRunnable - exception during job execution: JobEntity [id=9] was updated by another transaction concurrently
org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=9] was updated by another transaction concurrently
at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:286) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:834) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:798) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:595) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:211) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:137) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.handleMultipleJobs(ExecuteJobsRunnable.java:94) [activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:49) [activiti-engine-5.17.0.jar:5.17.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
14:57:17.825 [main] DEBUG o.a.e.i.interceptor.LogInterceptor -

I have attached the test case documents also, please look into it and provide some inputs to resolve this issue.

Regards,
Dinesh

jbarrez
Star Contributor
Star Contributor
I tried running your unit test:
- I had to remove both taskListeners (as they referenced a class I didn't have
- At the end, the assertion  assertNull(task1); false. Because the timer fires and it goes to the escalation task.
- if I uncomment    assertEquals("Escalation", task1.getName());, it runs green

The optimistick lock exception that you see seems to indicate something else is executing jobs. So did you check if you enabled the job executor? Disabling it should fix the test. Or do you have another engine maybe running against the same schema?

dinesh_babu_p
Champ in-the-making
Champ in-the-making
Hi, jbarrez,

In our application as mentioned earlier there are two timers,
1) Just send Email Notification after a minute (PT1M). This timer is a boundaryTimerEvent on approval task (UserTask)
2)Auto Decision timer exactly on same approval task (UserTask) which fires after 2 minutes (PT2M), it has a listener class which cannot be instantiated. If I remove the timer and try to call that class in my flow, the class can be instantiated and the flow is working fine,

But whenever it has to instantiate a class after Cancelling the approval task (UserTask), its not able to perform the operation.

I made the property jobExecutorActivate="TRUE" and I have only one processEngine in my application.

Regards,
Dinesh

Hi Dinesh,

Can you please let me know, how the issue was resolved. I am getting similar Not able to instantiate error.

Thanks !!!

dinesh_babu_p
Champ in-the-making
Champ in-the-making
Hi,
Thanks for the valuable inputs provided by you.

we have attached the activiti.cfg.xml file, TestTimer2.bpmn and MyUnitTest.java file.
we have written the JUnit test cases for the process.
we are getting the following failure case reason,

org.activiti.engine.ActivitiException: couldn't get table counts
at org.activiti.engine.impl.persistence.entity.TableDataManager.getTableCount(TableDataManager.java:146)
at org.activiti.engine.impl.cmd.GetTableCountCmd.execute(GetTableCountCmd.java:30)
at org.activiti.engine.impl.cmd.GetTableCountCmd.execute(GetTableCountCmd.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.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.ManagementServiceImpl.getTableCount(ManagementServiceImpl.java:53)
at org.activiti.engine.impl.test.AbstractActivitiTestCase.assertAndEnsureCleanDb(AbstractActivitiTestCase.java:137)
at org.activiti.engine.impl.test.AbstractActivitiTestCase.runBare(AbstractActivitiTestCase.java:123)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:252)
at junit.framework.TestSuite.run(TestSuite.java:247)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
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: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=MSVIZ.ACTIVITY, DRIVER=3.67.27
### The error may exist in org/activiti/db/mapping/entity/TableData.xml
### The error may involve org.activiti.engine.impl.TablePageMap.selectTableCount-Inline
### The error occurred while setting parameters
### SQL: select count(*) from ACTIVITY
### Cause: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=MSVIZ.ACTIVITY, DRIVER=3.67.27
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66)
at org.activiti.engine.impl.db.DbSqlSession.selectOne(DbSqlSession.java:441)
at org.activiti.engine.impl.persistence.entity.TableDataManager.getTableCount(TableDataManager.java:186)
at org.activiti.engine.impl.persistence.entity.TableDataManager.getTableCount(TableDataManager.java:142)
… 26 more
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=MSVIZ.ACTIVITY, DRIVER=3.67.27
at msjava.dbpool.connectionwrapper.internal.JdbcProxyingUtils$SQLExceptionHandlingInvocationHandler.invoke(JdbcProxyingUtils.java:230)
at com.sun.proxy.$Proxy22.execute(Unknown Source)
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:62)
at com.sun.proxy.$Proxy23.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:59)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:73)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:60)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
… 31 more

When we run the test case using default process engine with default database, my test cases are passing successfully.
But it fails when the test cases are made through custom spring based process engine. (activiti.cfg.xml file) which i have attached here. We feel that there is issue with the configuration. Please provide us the solution for this issue.

Waiting for your response.

Regards,
Dinesh