Dependency Injection is not working for my JavaDelegates and TaskListeners. It works for neither Flowable beans (e.g., RuntimeService) nor application EJB beans. In the other parts of the application, dependency injection works for both of them.
I use Flowable 6.4.2 with the CdiStandaloneProcessEngineConfiguration on TomEE 7.1.1, and I use the flowable:class attribute in the BPMN 2.0 XML file.
I followed the documentation on setting up Flowable with CDI.
I’ve never used Flowable with CDI, but in general flowable:class uses the new operator to instantiate your delegates. Your best bet is to use flowable:expression or flowable:delegateExpression so the beans can be injected/autowired.
That’ s too bad because it keeps me from migrating to Flowable. For Camunda, injection works with camunda:class too. My JavaDelegates and TaskListeners are not stateless, so I cannot easily switch to flowable:expression and flowable:delegateExpression.
Do you have an example xml of where the class injection is working? I’m trying to see if this was old behavior that was working differently in the past.
A delegateExpression should give you the same behavior (as no new instance is created). However, do note that in multi-threaded usages this can lead to unforseen behavior.
I need separate instances for each invocation. Otherwise, I will get unforeseen behavior when multiple activity instances execute concurrently as my delegate is not stateless.
In Camunda injection works, in Flowable it does not.
Ok, i think we were indeed talking about different things. I thought you mean class injection, but you mean injection of other services/beans into your service task class Foo in this example?
My CDI is quite rusty. Can you give an example how that Foo service task looks like (doesn’t need the logic, just the injection part).