AnsweredAssumed Answered

Autowired object(userService) is null within CustomTaskListener code

Question asked by paiyyavj13 on May 5, 2017
Latest reply on May 8, 2017 by cjose

Hi,

 

I am writing a custom TaskListener with the below code: I have hooked this TaskListener to Complete event of a User Task. I noticed that all the Autowired objects are null.

I am not efficient in Spring, am I missing a step by which I can properly Autowire these objects? Please assist!

 

Regards.

 

Sample Code:

package com.activiti.extension.bean;

 

@Component("customTaskListener")
public class CustomTaskListener implements TaskListener {

private static final long serialVersionUID = 4218009794670685270L;

private static final Logger logger = LoggerFactory.getLogger(CustomTaskListener.class);

@Autowired
private HistoryService historyService;
@Autowired
private UserService userService;

@Override
public void notify(DelegateTask delegateTask) {
//...removed custom code for this post
//Here userService is null
User subTaskUser = userService.getUser(subTaskAssigneeId);

}
}

Outcomes