简体   繁体   中英

Null pointer exception while starting a process outside Alfresco Activiti

I am using Alfresco Activiti and want to initiate a task outside of it. I have written a standalone java program to do this (ie my java program creates a task in alfresco activiti on execution).

    TaskService taskService=processEngine.getTaskService();
    Task task=taskService.createTaskQuery().taskAssignee("USER MAYA SHARMA").singleResult();

    System.out.println(task.getName());

The program runs fine as long as my taskAssignee is $INITIATOR, but when I change my taskAssignee to a real user in alfresco activiti, it throws a null pointer exception.

Exception in thread "main" java.lang.NullPointerException at TestingABC.main(TestingABC.java:34)

NullPointerException occurs when you try to call a method on a null Object. For example:

String aNullString = null;
aNullString.indexOf("");

will give a NullPointerException because aNullString is null , which does not have any methods.


If your error is occurring on the first line you posted, then that means processEngine is null .

If the error is thrown on the second line, then either:

  1. taskService
  2. taskService.singleResult

is null

If the error is thrown on the third line, then task is null .

Please edit your post so that I know which line you posted is throwing the error so I can give a more detailed response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM