AnsweredAssumed Answered

Accessing annotated spring beans in an expression

Question asked by ikazarno on Oct 13, 2013
Latest reply on Oct 15, 2013 by ikazarno
Hi,

today is a first day I’m experimenting with activiti. It seems to be a nice framework, thanks guys :)

I have a problem accessing an annotated spring bean in a service task expression:

<serviceTask id="servicetask" name="Service Task" activiti:expression="#{myService.performAction()}"></serviceTask>

My service bean looks as follows:

@Service("myService")
public class MyServiceImpl implements Serializable {
  public void performAction() {
    // some business logic
  }
}

My Unit Test Code:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:test-config.xml"})
public class MyWorkflowTest {

   @Autowired
   @Rule
   public ActivitiRule activitiSpringRule;

   @Test
   public void testMyProcess() {
      RuntimeService runtimeService = activitiSpringRule.getRuntimeService();
      runtimeService.startProcessInstanceByKey("myProcess");
   }
}

If I execute the test I get following error:
org.activiti.engine.ActivitiException: Unknown method used in expression: #{myService.performAction()}
Caused by: org.activiti.engine.impl.javax.el.MethodNotFoundException: Cannot find method perform with 0 parameters in class com.sun.proxy.$Proxy25
   at org.activiti.engine.impl.javax.el.BeanELResolver.invoke(BeanELResolver.java:476)
   at org.activiti.engine.impl.javax.el.CompositeELResolver.invoke(CompositeELResolver.java:397)

If I put the bean in the spring config, it works! Can I use the annotated beans, without defining them in the spring config?

Thanks in advance!
Igor

Outcomes