AnsweredAssumed Answered

An error while getting groups assigned to user task

Question asked by bars on Oct 15, 2011
Hello.
I’m trying to get list of groups assigned to user task using the following code (class implements TaskListener):
private static List<String> getTaskGroups(String taskId) {
      List<String> taskGroups = new ArrayList<String>();
      List<IdentityLink> identityLinks = processEngine.getTaskService()
            .getIdentityLinksForTask(taskId);
      for (IdentityLink identityLink : identityLinks) {
         if (identityLink.getType().equals("candidate")) {
            taskGroups.add(identityLink.getGroupId());
         }
      }
      return taskGroups;
   }
If  I use “complete” event in user task, it works. But if I try to get groups while task creation (“create” event)- I receive an exception:
"org.springframework.extensions.webscripts.WebScriptException - 09140003 Wrapped Exception (with status template): null",
  "java.lang.NullPointerException"
"org.activiti.engine.impl.cmd.GetIdentityLinksForTaskCmd.execute(GetIdentityLinksForTaskCmd.java:44)"
,"org.activiti.engine.impl.cmd.GetIdentityLinksForTaskCmd.execute(GetIdentityLinksForTaskCmd.java:29)"
,"org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)"
,"org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)"
,"org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)"
,"org.activiti.engine.impl.TaskServiceImpl.getIdentityLinksForTask(TaskServiceImpl.java:135)"
      ,"com.company.core.GroupHelper.getTaskGroups(GroupHelper.java:41)"
      ,"com.company.core.GroupHelper.notify(GroupHelper.java:33)"
      ,"org.activiti.engine.impl.bpmn.helper.ClassDelegate.notify(ClassDelegate.java:87)"
,"org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:507)"
,"org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.execute(UserTaskActivityBehavior.java:70)"
,"org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)"
      ,"org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)"
,"org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)"
,"org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:48)"
,"org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)"
,"org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)"
…….
what is wrong here? Recommend me, please, how can I get user groups while task creation.
Thx

Outcomes