cancel
Showing results for 
Search instead for 
Did you mean: 

Task listener and expression

nik10_mah
Champ in-the-making
Champ in-the-making
Hi,

I am using a task listener and instead of using a class attribute i have used expression attribute. but it given me exception:

org.activiti.engine.ActivitiException:Exception while invoking TaskListener: Unknown property used in expression: ${messageProcess.chooseAction(task)}

where messageProcess is my spring bean and choose action is method in it. I have added @Component("messageProcess") spring annotation so that my listener gets loaded into spring context. But when i start the process it gave me above exception.

I have attached full stacktrace, my bpmn file and MessageProcessListener.java.

Please let me know if there are any issue in my code.

Thanks
2 REPLIES 2

nik10_mah
Champ in-the-making
Champ in-the-making
An update on my query.
I tried with class attribute instead of expression for listener and it worked however the inject spring bean was giving null pointer.

And other this is i am using standalone configuration for creating the process engine as i have implemented multitenancy with multiple databases so the SpringProcessEngineConfiguration was giving me issues.

Please let me know if there is the issue with the configuration.

Thanks

c-shark
Champ in-the-making
Champ in-the-making
Here is a configuration to start activiti process engine in a spring context. And yes, you need to start it this way, because the listener classes started by activiti engine, and if you want to use Spring autowiring, you need a spring context that manages the beans.
<code>
  <context:annotation-config />
  <tx:annotation-driven transaction-manager="activitiTransactionManager"/>
  <!– For async task running –>
  <task:annotation-driven />
  <!– Activiti service beans –>
  <context:component-scan base-package="my.service.beans" />



  <bean id="activitiTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="activitiDataSource" />
  </bean>

  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>
 
  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="databaseType" value="postgres" />
    <property name="dataSource" ref="activitiDataSource" />
    <property name="transactionManager" ref="activitiTransactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jobExecutorActivate" value="false" />
  </bean>

  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
  <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
  <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />


  <bean id="activitiDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    <property name="driverClass" value="org.postgresql.Driver" />
    <property name="url" value="jdbcSmiley Tongueostgresql://localhost:5432/activiti" />
    <property name="username" value="postgres" />
    <property name="password" value="secret" />
  </bean>

</code>

Hope it helps.