AnsweredAssumed Answered

Injecting a Service in a TaskListener returns Null

Question asked by artemas on Nov 7, 2016
Latest reply on May 17, 2018 by papalanisamy@inautix.co.in
I have a TaskListener assigned to a task in my Activiti Workflow. The issue I'm having is injecting a Service as it returns null when I try to access methods in that Service. The Class below is located in my extension at:
my-project-activiti-extensions/src/main/java/com/custom/bpmn/listner/TestListener.java 



package com.custom.bpmn.listner;

import com.activiti.service.api.UserService;

@Component
public class TestListener implements TaskListener {

   private static final long serialVersionUID = 1L;
    private static final Logger logger = LoggerFactory.getLogger(TestListener.class);

    @Autowired
    private UserService userService;

   @Override
   public void notify(DelegateTask delegateTask) {

      long userId = new Long((String)delegateTask.getVariable("currentUser")).longValue();
      String previousAssignee = userService.findUser(userId).getExternalId();

   }
}

Each time I try to access the UserService, it's always null and returning a
Null Pointer Exception
although the userId exists.

Outcomes