This is the best I can do. Of any use?
String processInstanceId = (set somewhere) => Tomcat in debug mode shows it has value 7
TaskService taskService = processEngine.getTaskService();
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).uniqueResult();
taskService.completeTask(task.getId());
I get a NullPointerException, because task is null. Looking in the database, its procinst_ field is set to 7.
(I use the uniqueResult because there can only be one task at this stage for the process instance)