cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti unable to reference Spring beans.

unsavory
Champ on-the-rise
Champ on-the-rise
I am attempting to access a spring bean using the following expression:
<conditionExpression xsi:type="tFormalExpression">${ userService.isAutoRejectCandidate(userService.getUserByEmail(email)) }</conditionExpression>

But the following exception is thrown when doing so:
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'userService'
   at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
   at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)
   at org.activiti.engine.impl.juel.AstMethod.eval(AstMethod.java:75)
   at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)
   at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)
   at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
   at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:46)
   … 166 more

Here is my Spring configuration:
<!–
   ~~~~~~~~~~~~~~~~~~  ACTIVITI BPM  ~~~~~~~~~~~~~~~~~~
   –>
   
   <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="true" />
      <property name="deploymentResources" value="classpath*:/seah/bpm/*.bpmn20.xml" />
   </bean>
 
   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
      <property name="processEngineConfiguration" ref="processEngineConfiguration" />
   </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="identityService" factory-bean="processEngine" factory-method="getIdentityService" />

I should not that userService is a spring bean in my Spring application context configured via the @Service annotation. 

This is how I use/reference Activiti in my application:
@Resource
   private ContractRepository contractRepository;
   
   @Resource
   private RepositoryService repositoryService;
   
   @Resource
   private RuntimeService runtimeService;
   
   @Resource
   private TaskService taskService;
   
   @Resource
   private HistoryService historyService;
      
   @Resource
   private IdentityService identityService;

Any ideas why Activiti cannot see my Spring beans?
1 REPLY 1

unsavory
Champ on-the-rise
Champ on-the-rise
In case this helps someone else in the future, I was able to get it to resolve my Spring service by changing the annotation on the service from @Service to @Service("userService").