cancel
Showing results for 
Search instead for 
Did you mean: 

How can use mine service on TaskListener?

croc1
Champ in-the-making
Champ in-the-making
Hi
I want to use mine service interface on TaskListener?
the service in spring context
like this

@Component
public class ListenerK implements TaskListener{
   
   @Resource SysUserService sysUserService;
   
   public void notify(DelegateTask delegateTask) {
      System.out.println(sysUserService);
      
   }

}
but the service is null.why?
4 REPLIES 4

croc1
Champ in-the-making
Champ in-the-making

<bean id="jServ" class="demo.JServ" />
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="dataSource" ref="dataSource" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="databaseSchemaUpdate" value="true" />
  <property name="jobExecutorActivate" value="false" />
  <property name="beans">
   <map>
    <entry key="jServ" value-ref="jServ" />
   </map>
  </property>
</bean>

also null…

jbarrez
Star Contributor
Star Contributor
How do you call the service in your process? Ie how does your xml look like?

croc1
Champ in-the-making
Champ in-the-making

<userTask id="usertask1" name="User Task" activiti:assignee="3">
      <extensionElements>
        <activiti:taskListener event="create" class="demo.ListenerK"></activiti:taskListener>
      </extensionElements>
    </userTask>

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Use activiti:expression instead of activiti:class. Then your listener will be 'injected' with services etc afaik.