cancel
Showing results for 
Search instead for 
Did you mean: 

NPE when completing a task

robdiana
Champ in-the-making
Champ in-the-making
Recently, we started to have one workflow throw a NullPointerException when trying to complete the first task in the workflow. This is a user task that is being completed, so no other operations on the workflow are happening at the same time. We have other workflows that are functioning correctly.

We are running v5.16.4 and using the standalone process engine (programmatic configuration) with some basic JDBC credentials.

Any ideas why this would be occuring or why it would suddenly start being a problem after at least a month of using the workflow? Below is the relevant stack trace.

2015-10-06 12:28:35.883 rsuite-server WARN http-bio-8080-exec-840 <RestAPIv1.req-3910> org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation - NullPointerException
java.lang.NullPointerException
at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.sameIdentity(DbSqlSession.java:263)
at org.activiti.engine.impl.db.DbSqlSession.removeUnnecessaryOperations(DbSqlSession.java:609)
at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:571)
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:211)
at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:137)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
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.TaskServiceImpl.complete(TaskServiceImpl.java:175)
6 REPLIES 6

martin_grofcik
Confirmed Champ
Confirmed Champ
Could you reproduce the issue in jUnit test?
http://forums.activiti.org/content/sticky-how-write-unit-test

Regards
Martin

I am not able to reproduce with a unit test. I was also told that the environment this is failing in is using MySQL 5.0.77, which is not the version I am using locally. Is there some DEBUG logging I could turn on that would give me a better clue as to what is going on? Or is there some direction on how to dig into this type of issue?

trademak
Star Contributor
Star Contributor
Really strange, because it looks like one of the persistent objects has a null id value. The id value should always have a non null value. If it's possible to know which persistent object is causing the problem that would be great. I don't see a possibility to get more logging from the Activiti code.

Best regards,

david_miller
Champ in-the-making
Champ in-the-making

I also am having the same problem.  The same business process was working fine under PostgreSQL; the problem has appeared after switching to MySQL (version 5.7.17).  Did you find a solution?  I can reproduce in a unit test, but I have to load my entire application, so I can't share the test... It must be something in my application code that is causing the problem, since if I run the same test with only Activiti classes, it works well.

I have found the problem.

I registered a pre-BPMN parse handler.  This parse handler sends all task events (create, assign, complete, delete, save) to a Spring event handler.  The Spring event handler looks up certain information about the task.  In particular, it uses the TaskService to find identity links for the task.  For create, assign, and save events, this doesn't seem to be a problem.  For delete and complete events, it causes the NullPointerException in CheckedDeleteOperation.sameIdentity method, as described in the original post.

The fix will be to detect when the event handler is running from a complete or delete event (where we don't care about identity links anyway), and not lookup identity links.

Same code did work with PostgreSQL though.  MySQL obviously has some different concurrency model... I am running under InnoDB which supposedly supports multi-version concurrency control (MVCC).

I just verified this works fine.  Moral of the story: when running with MySQL, do not lookup identity links during your event handler for task complete and delete events.