Service task not able to find JavaDelegate class bean when "asyncExecutorActivate" is true

This is my BPMN process
BusinessRuleLoanProcess
When I give class Java class to service task, it’s working fine. But when I’m giving Delegate expression of JavaDelegate class bean as mentioned in this post, it throws the error “Unknown property used in expression: ${loanService}”. This is happening only when I set “asyncExecutorActivate” to true, but it was required as I have a timer start event.

This is how I’m declaring JavaDelegate class

@Component
public class LoanService implements JavaDelegate {

public void execute(DelegateExecution arg0){

I want to give JavaDelegate class as a Delegate expression to the Service task because I will be Autowiring other services into this class. As of my knowledge, this cannot be done when JavaDelegate is given as Java class to Service task.

How to make this work?

Thanks in advance

Yes you are right that a JavaDelegate needs to be managed by Spring in order to wire in other Spring dependencies. I am not sure why your Service Task is not working correctly when the async executor is active, its either because the LoanService bean is not really registered with Spring or there is an issue with the expression manager used to resolve the placeholder ${loadService}. You should first verify the bean exists in Spring, maybe by searching for it in the application context. Flowable uses a list of expression resolvers to resolve placeholders and expression values. The expression resolver pertinent to your case is the ApplicationContextElResolver class, which should be set up by Flowable. The following method in this class is used to resolve bean names from the Spring context:

@Override
public Object getValue(ELContext context, Object base, Object property) {
    if (base == null) {
        // according to javadoc, can only be a String
        String key = (String) property;

        if (applicationContext.containsBean(key)) {
            context.setPropertyResolved(true);
            return applicationContext.getBean(key);
        }
    }

    return null;
}

You could try setting a break point in this method to see why the expression is not working.

Thank you for the reply. As you have said, it has nothing to do with the async executor. After some research, I found out that the mistake I made was using StandaloneInMemProcessEngineConfiguration in the spring boot application. That’s why flowable was not able to find the bean.
When I used SpringProcessEngineConfiguration to build the process engine, the service task is working fine.

Then another problem raised with Business Rule Task. I have opened another topic. Please see if you have any inputs on that.

Thanks.