3 Replies Latest reply on Jun 23, 2010 1:08 AM by Michael Wohlfart

    Calling TaskService.CompleteTask from inside a Java callback

    Joe Gottman Newbie

      After a task is assigned, I would like to use a Java callback to run some code and then call TaskService.CompleteTask() on the task.  I tried calling CompleteTask from both an AssignmentHandler class and an EventListener that listended for the Task's assign event.  In both cases, an exception was thrown. 


      When I called it from the AssignmentHandler, CompleteTask() threw an IllegalArguementException with the message "id to load is required for loading".


      When I called it form the assign EventListener, CompleteTask() and my EventListener's notify() method complete without an error, but later a NullPointerException is thrown because the following code at lines 116 and 117 of the org.jbpm.jpdl.internal.activity.TaskActivity class's signal method:


      TaskImpl task = (TaskImpl) taskDbSession.findTaskByExecution(execution);




      In the first line, an null task is returned, and so the second line causes the NullPointerException.


      I would appreciate any advice on how to safely call TaskService.CompleteTask from an AssignmentHandler, an EventListener, or any other Java callback accessable from a Task.