cancel
Showing results for 
Search instead for 
Did you mean: 

NPE on engine.getTaskService().createTaskQuery()

markvt
Champ in-the-making
Champ in-the-making
NPE on engine.getTaskService().createTaskQuery()

Hi,

We are experiencing a NPE on making this activity query call:

engine.getTaskService().createTaskQuery().taskId(taskId).includeProcessVariables().singleResult();

This only happens very occasionally and we have not found a way to reproduce the error. Nether occasion has been during any heavy load though both occasions have been at the same point in the BPMN where two parallel flows are executing a task each before entering an inclusive gateway. What we see is this error on the first task:


### Error querying database.  Cause: java.lang.NullPointerException
### Cause: java.lang.NullPointerException
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.NullPointerException
### Cause: java.lang.NullPointerException
                at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) ~[mybatis-3.2.5.jar:3.2.5]
                at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107) ~[mybatis-3.2.5.jar:3.2.5]
                at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) ~[mybatis-3.2.5.jar:3.2.5]
                at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameterWithoutFilter(DbSqlSession.java:426) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.persistence.entity.TaskEntityManager.findTasksAndVariablesByQueryCriteria(TaskEntityManager.java:139) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.TaskQueryImpl.executeList(TaskQueryImpl.java:930) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.AbstractQuery.executeSingleResult(AbstractQuery.java:158) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.AbstractQuery.execute(AbstractQuery.java:141) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) ~[activiti-spring-5.16.1.jar:5.16.1]
                at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.1.3.RELEASE.jar:4.1.3.RELEASE]
                at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) ~[activiti-spring-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) ~[activiti-engine-5.16.1.jar:5.16.1]
                at org.activiti.engine.impl.AbstractQuery.singleResult(AbstractQuery.java:104) ~[activiti-engine-5.16.1.jar:5.16.1]

and 1/10th of a second later the other task correctly makes this query call and continues on while the first leg is left in as stalled state and never reaches the gateway.

We have looked at past forum posts and note that it seems very similar to an old bug fixed in version 5.13 (while we are on a much later version 5.17) :

https://forums.activiti.org/content/npe-variables-get-processinstance-loaded-processinstancequery

That particular bug raised was on a createProcessInstanceQuery() while we are using a taskQuery. Is it possible the bug was fixed only for processInstance queries? (The old link to the fix is no longer available).

Can you shed any light on what this issue might be and why it could be happening so infrequently?

For now it seems that our only workaround is a crude one - wrapping this call in a try/catch, waiting and then retrying a specific number of times before failing
3 REPLIES 3

erikwinlof
Confirmed Champ
Confirmed Champ
Just a quick answer for now if you want to continue pursuing it:
The link from the other forum post was incorrect due to a trailing "." follow this link to see the commit
https://github.com/Activiti/Activiti/commit/136859b6e4100d80c34bfc5c43964c8c8e4362de

erikwinlof
Confirmed Champ
Confirmed Champ
Since this very much sounds like a bug, please file it in github instead and lets continue the conversation there:
https://github.com/Activiti/Activiti/issues

..also supply your process so it can be reproduced (I understand it doesn't happen every time but having a unit test that sometimes reproduces it is better than nothing), see link below for a starting point to easily create a unit test for Activiti with a process definition:
https://github.com/Activiti/Activiti/tree/master/tooling/archetypes/activiti-archetype-unittest


markvt
Champ in-the-making
Champ in-the-making
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.