cancel
Showing results for 
Search instead for 
Did you mean: 

Exception while invoking TaskListener: null

praveenshanmuga
Champ in-the-making
Champ in-the-making

I implement the TaskListener, i gotr the exception while task being created.

code are

long workflowTaskId=0l;
long compId=0l;
@Override
public void notify(DelegateTask arg0) {
// TODO Auto-generated method stub
workflowTaskId=Long.parseLong(arg0.getId());
compId=Long.parseLong(arg0.getTenantId());

System.out.println("Company ID "+compId);

System.out.println("%%%%%%%Activiti Working*****************"+ arg0.getProcessInstanceId()+" "+arg0.getName()+arg0.getId());

getMethod();
}

private void getMethod(){

try{
Company company = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
//compId = company.getGroup().getGroupId();
}catch(PortalException e){}
catch (SystemException se) {
// TODO: handle exception
}

try{

System.out.println("workflowTaskId "+workflowTaskId);
System.out.println(WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId));
System.out.println(WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId).getOptionalAttributes());
System.out.println(WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId).getOptionalAttributes().get("entryClassPK"));

String classPk= WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId).getOptionalAttributes().get("entryClassPK").toString();
System.out.println("classPk "+classPk);
long fileEntryId=DLFileVersionLocalServiceUtil.getFileVersion(Long.parseLong(classPk)).getFileEntryId();
System.out.println("fileEntryId "+fileEntryId);
String name=DLFileVersionLocalServiceUtil.getFileVersion(Long.parseLong(classPk)).getTitle();
System.out.println("name "+name);
long chapfoldId=DLFileVersionLocalServiceUtil.getFileVersion(Long.parseLong(classPk)).getFolderId();
System.out.println("chapfoldId "+chapfoldId);
long bkfoldId=DLFolderLocalServiceUtil.fetchFolder(chapfoldId).getParentFolderId();

System.out.println("MytaskcreateListener Called \nworkflowTaskId "+workflowTaskId+"\nclassPk "+classPk+"\nfileEntryId "+fileEntryId+"\tname " +name+"\tbook "+bkfoldId );

}catch(PortalException p){}
catch (SystemException see) {
// TODO: handle exception
}

}
}

7 REPLIES 7

gdharley
Elite Collaborator
Elite Collaborator

What event do you have the tasklistener registered against?

If it is the assign event, you may not have a fully populated task which could lead to such an NPE.

Cheers,

Greg

event : create 

the Bpmn's xml code

<userTask id="usertask1" name="Update Due Date" activiti:candidateGroups="Administrator,Power User">
<extensionElements>
<activiti:taskListener event="create" class="com.library.model.listeners.MyTaskCreateListener" />
</extensionElements>
</userTask>

Ok, so it isnt the partially populated task object that is the problem.

Perhaps you have no tenant associated. Can you tell us what line the NPE is coming from (i.e. stack trace)?

Thanks,
Greg

String classPk= WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId).getOptionalAttributes().get("entryClassPK").toString();

The above mentioned line make NPE, and give warning is cannot find taskId 

Ok, so I see now why you wont attach a stack trace.
It appears as though you are using the Liferay-Activiti connector and the error is coming out of the Liferay code.

Can you confirm the workflowTaskId is populated with a valid id?

Thx,

Greg

The populated workflowTaskId is a valid id, its confirmed

If that's the case then the issue lies within the Liferay library.

Not sure I can hlp with that have never used the plugin, perhaps someone else on teh forum has worked with the Liferay module.

Greg