Accessing annotated spring beans in an expression

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2013 05:50 PM
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
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
Labels:
- Labels:
-
Archive
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2013 07:49 AM
I guess, you need to use $ instead of # in EL expressions. I mean try ${myService.performAction()} instead of #{myService.performAction()}

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2013 07:11 AM
It would be great if the problem could be solved so easy. But according to the user guide you can use # in expressions…
I think the problem is due to the fact that org.activiti.engine.impl.javax.el.BeanELResolver gets a proxy instead of a real object from the spring context evaluating the expression. The question now is whether there is a solution for this problem that allows me to use my annotated beans or I have to define all my spring beans in a XML configuration file.
I think the problem is due to the fact that org.activiti.engine.impl.javax.el.BeanELResolver gets a proxy instead of a real object from the spring context evaluating the expression. The question now is whether there is a solution for this problem that allows me to use my annotated beans or I have to define all my spring beans in a XML configuration file.
