I am using activiti 5.16.1 to enable workflow in my project.
I have a spring beans which carry out business task such as populating data from database for a given id.
When I try to use these beans in JavaDelegate task, these beans are not populated.
@Component
public class ServiceClassDelegateSample implements JavaDelegate {
@Autowired
private SampleService sampleService;
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
sampleService.doSomeTask();
}
}
However sampleService is always set to null.
Are you aware of how to use spring beans in JavaDelegate task?
There is similar question here without any proper solution and I hope there is better way in newer version of Activiti.
If I remember correctly, it is some kind of glitch in Activiti, but you can easily solve it if you replace
<serviceTask id="servicetask" name="Service Task" activiti:class="some.class.path.ServiceClassDelegateSample"></serviceTask>
with delegate expression;
<serviceTask id="serviceTask" activiti:delegateExpression="${serviceClassDelegateSample}"></serviceTask>
where serviceClassDelegateSample
is a name of your bean.
But why doesn't work in first way, I don't know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With