Spring beans not injected into Flowable context

I know this thread is a little old, but for the benefit of those who sailed into here via Google and have similar issue, here the solution that worked for me. If you want your service delegate to be Spring managed and injected into the workflow, you can do the following steps:

  1. Create service delegate bean in Spring:

@Component
public class JavaSpringManagedDelegate implements JavaDelegate {

@Override
public void execute(DelegateExecution execution) {

  //delegate code

}

}

Through the magic of component scanning and naming convention, Spring will create a bean named “javaSpringManagedDelegate”.

  1. This bean instance can be used in Java service activity by setting the delegateExpression attribute to “${javaSpringManagedDelegate”, i.e. use the field named Delegate Expression: in the modeler.

When flowable executes this activity, it will pull this bean from Spring’s application context and call the execute method.

2 Likes