I am working in a spring boot application.
when i try to call tasklistener class, The autowired historyservice is returning null.
Can anyone please help !
Solved! Go to Solution.
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,
Thanks for your prompt response.
We are using SPRING BOOT .
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>
this is spring boot application. anything specific for springboot ??
Hi,
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.
Regards,
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.
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>
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.