RemoteIdmService is null when using a TaskListener

I have created a TaskListener and I am using the flowable-ui-task-app. When the listener executes the RemoteIdmService is null.

@Component
public class AssignEmailListener implements TaskListener {

@Autowired
private RemoteIdmService remoteIdmService;

private static final long serialVersionUID = 1L;

public void notify(DelegateTask arg0) {
	DelegateTask task = arg0;
	String assignee = task.getAssignee();
	if (assignee == null) {
		System.out.print("assigned to group");
	} else {
		System.out.println("assignee = " + assignee);
		User user = remoteIdmService.getUser(assignee);
		System.out.println(user.getEmail());
	}
}

}

I have tried to Autowire other services and they are also null. What needs to be done to use the services in the TaskListener?

  • which package does your taskListener have? i.e. is it scanned by component scanning?
  • how did you configure the listener in the process? i.e. is it a spring bean delegation?

The package is org.flowable.app.extension.bean

I have tried with both class and Delegate Expression

<userTask id="sid-A78294D0-B3A6-4976-AFC3-0FC871712BF3" flowable:assignee="admin">
  <extensionElements>
    <flowable:taskListener event="assignment" delegateExpression="org.flowable.app.extension.bean.AssignEmailListener"></flowable:taskListener>
    <modeler:activiti-idm-assignee xmlns:modeler="http://flowable.org/modeler"><![CDATA[true]]></modeler:activiti-idm-assignee>
    <modeler:assignee-info-email xmlns:modeler="http://flowable.org/modeler"><![CDATA[admin@flowable.org]]></modeler:assignee-info-email>
    <modeler:assignee-info-firstname xmlns:modeler="http://flowable.org/modeler"><![CDATA[Test]]></modeler:assignee-info-firstname>
    <modeler:assignee-info-lastname xmlns:modeler="http://flowable.org/modeler"><![CDATA[Administrator]]></modeler:assignee-info-lastname>
    <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
  </extensionElements>
</userTask>

I changed the code to use the applicationContext and it now it works.