I am working in a spring boot application. when i try to call tasklistener class, The autowired historyservice is returning null.
process service tasklistener
Can anyone please help !
Thanks both of you..
Finally the issue is solved by passing the listener in delegate expression instead of class .
<activiti:taskListener event="all" delegateExpression="${TestClass}"></activiti:taskListener>
TaskListeners that are set in 'class' attribute are created/instantiated by the engine so Spring autowiring will not work.
<activiti:taskListener event="complete" class="example.MyTaskListener">
Hi,
As Bassam Al-Sarori mentioned task listeners are basically bind in context of task and workflow so it should be set in your workflow tasks, not separated wired as a spring bean .
Regards,
Rupesh
Hi Bassam,
Thanks for your prompt response.
Here is my code. any changes to be done for this.
public class TestClass implements TaskListener { @Autowired private HistoryService historyService; public void notify(DelegateTask delegateTask) { String currentEvent = delegateTask.getEventName(); if("delete".equalsIgnoreCase(currentEvent)) return; try { System.out.println(historyService);// it returns null, please let us know the workaround } } XML File : <activiti:taskListener event="all" class="com.callback.TestClass"></activiti:taskListener>
Hi Rupesh,
We are using SPRING BOOT .
this is spring boot application. anything specific for springboot ??
Here i think you may have to depends-on attribute on task listener class the way it is added in following bean definition.
<bean id="abc" class="com.test.ABC" parent="baseJavaDelegate" depends-on="activitiBeanRegistry" abstract="true">
I think this will help you.
Rupesh Sawaliya
EnProwess Technologies
You can try registering your task listener as a spring bean (i.e. using @Component)and use an expression to call it.
<activiti:taskListener event="all" expression="${myTaskListener.notify(execution)}" />
By the way, it could be any class (spring bean) doesn't have to implement TaskListener.