Flowable Springboot application deployment in Flowable Task app

Hi,
I have created a spring boot application which has some Java Delegates and Using the Autowired feature of Springboot to get the runtimeService. Here is the code for the same.

@Component(“checkEMail”)
public class CheckEMailAddress implements JavaDelegate {

private static final Logger LOGGER = LoggerFactory.getLogger(CheckEMailAddress.class);

@Autowired
private RuntimeService runtimeService;

@Autowired
private TaskService taskService;

@Override
public void execute(DelegateExecution execution) {

	LOGGER.info("Checking the e-mail Address");
	runtimeService.setVariable(execution.getProcessInstanceId(), "isEmailExists", false);
	
}

}

I did a maven clean install and Used the jar file (Not the fat jar). Copied the jar file into the WEB-INF/lib folder of flowable-task app running in a tomcat. While running the process from task App I am getting null pointer for runtimeService.
Please suggest.

My guess is that you are using the “class” attribute on your service task instead of “delegateExpression”. Class will instantiate the delegate class without being Spring aware. I’m also guessing that your approach to extending the Flowable UI apps is insufficient to get your beans registered. [https://flowable.org/docs/userguide/index.html#custom-bean-deployment]

Major requirements:

  • A META-INF/spring.factories file to enable auto configuration
  • An @Configuration that adds your components

Here’s a project demonstrating how to do it:

2 Likes

Also, DelegateExecution has a setVariable method so you don’t need the runtime service for that purpose. If you needed other beans for some reason, you’d still need to work through getting them injected correctly.

Will

Thank you very much for the quick response. Will try to implement the same and will update.

Regards,
Subbu

Hi,
I’m having the same problem: other beans are not injected into my JavaDelegate class.
I followed the link to the Demo app, but this delegate is not injecting anythig:

@Component
public class DemoDelegate implements JavaDelegate {

    public void execute(DelegateExecution execution) {
        execution.setVariable("mmmbop", "It's Gone!");
    }
}

Is it possible to inject/autowire other beans inside a JavaDelegate?
My autowired beans are always null.