ServiceTask delegateexprssion is not honoring field settings
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2011 01:15 AM
If the service task is defined with delegateexpression it's not honoring fields that are defined in BPMN. The delegate gets instantiated but the fields are not set.
The code in BpmnParse.java line 902 when creating ServiceTaskDelegateExpressionActivityBehavior the fields are not parsed. Also the code ServiceTaskDelegateExpressionActivityBehavior doesn't handle the fields.
To me it's a defect even when we define delegate expression to load any spring bean we still want to wire some properties of that in BPMN. IMO the BPMN field definitions should be applied to delegate object.
I've patched the code I can submit the code if any one interested.
The code in BpmnParse.java line 902 when creating ServiceTaskDelegateExpressionActivityBehavior the fields are not parsed. Also the code ServiceTaskDelegateExpressionActivityBehavior doesn't handle the fields.
To me it's a defect even when we define delegate expression to load any spring bean we still want to wire some properties of that in BPMN. IMO the BPMN field definitions should be applied to delegate object.
I've patched the code I can submit the code if any one interested.
Labels:
- Labels:
-
Archive
8 REPLIES 8

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2011 02:57 AM
Hi,
In the user guide it says "Field injection is supported when using the 'class' attribute".
So it's not a bug, but more a feature request.
Could you explain your use case a bit more? What would you like to inject?
Best regards,
In the user guide it says "Field injection is supported when using the 'class' attribute".
So it's not a bug, but more a feature request.
Could you explain your use case a bit more? What would you like to inject?
Best regards,

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2011 03:34 PM
I am facing the same scenrio when working with 5.7 Activiti. I have this in my process
Where testExpressionDelegate is a Spring bean (which I am using as my delegate expression.) for a class that implements JavaDelegate
But the field1 is always null. Like you said, the field1 gets a value if I use this directly as a java class but I want to wire some things into this class and cannot use it like that.
Please let me know if you want more details or if this feature has already been added.
Thanks,
Sang
<serviceTask id="servicetask1" name="My Task Execution Service" activiti:delegateExpression="${testExpressionDelegate}">
<extensionElements>
<activiti:field name="field1">
<activiti:string>name</activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
Where testExpressionDelegate is a Spring bean (which I am using as my delegate expression.) for a class that implements JavaDelegate
public class MyTaskDelegate implements JavaDelegate {
@Autowired
private Service service;
private Expression field1;
/**
* @see org.activiti.engine.delegate.JavaDelegate#execute(org.activiti.engine.delegate.DelegateExecution)
*/
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
…
if (field1 != null) {
String field1AsString = (String) field1.getValue(delegateExecution);
…
}
}
But the field1 is always null. Like you said, the field1 gets a value if I use this directly as a java class but I want to wire some things into this class and cannot use it like that.
Please let me know if you want more details or if this feature has already been added.
Thanks,
Sang
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2011 05:08 AM
this is not supported… with expressions you can pass in parameters IN the expression, so that is the 'workaround'

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2011 06:22 PM
Well I understand that it can be done with expressions but I was using delegateExpression implementing the JavaDelegate interface so that I could get access to context (and all the process variables etc and not have to pass everything in as a parameter). Well, as a workaround I added an execution listener to the task and used that to interpret the field expressions.
Then I can get the field on my Service task delegate class (wired thro spring)
Let me know if you have any comments on this.
Thanks,
Sang
<activiti:executionListener event="start" class="MyTaskListener">
public class MyTaskListener implements ExecutionListener {
private Expression field1;
@Override
public void notify(DelegateExecution paramDelegateExecution) throws Exception {
if (field1 != null) {
paramDelegateExecution.setVariableLocal("field1", field1.getExpressionText());
}
}
Then I can get the field on my Service task delegate class (wired thro spring)
Object field1 = delegateExecution.getVariableLocal("field1");
Let me know if you have any comments on this.
Thanks,
Sang
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2012 12:07 PM
Anyone still interested in having this 'fixed'? (I volunteer)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2012 05:31 AM
Yes, please add this. It's also important for Activiti OSGI (which only supports delegateExpression).

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2012 06:26 AM
Okay, done as part of the Activiti Hack Days (see http://www.bpm-guide.de/2012/08/16/activiti-hack-days/) 🙂
See http://jira.codehaus.org/browse/ACT-1379 and http://jira.codehaus.org/browse/ACT-847
See http://jira.codehaus.org/browse/ACT-1379 and http://jira.codehaus.org/browse/ACT-847
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2016 03:20 AM
Is there something new about this?
I try to use it OSGI context and if i try to pass Expressions into my cached bean i got an error :
<blockcode>
Process task 302639 was signaled to leave.
2016-11-24 08:35:07,083 | WARN | m://client_queue | BpmnProducer | 45 - logger-logging - 1.0.0 | Error while Calling BPMN: org.activiti.engine.ActivitiIllegalArgumentException: Field definition uses unexisting field 'moduleName' on class Proxy8477823f_cf1d_4efb_8912_0b18301965d9
ActivitiIllegalArgumentException: Field definition uses unexisting field 'moduleName' on class Proxy8477823f_cf1d_4efb_8912_0b18301965d9
</blockcode>
i Use Version 5.19.3
I try to use it OSGI context and if i try to pass Expressions into my cached bean i got an error :
<blockcode>
Process task 302639 was signaled to leave.
2016-11-24 08:35:07,083 | WARN | m://client_queue | BpmnProducer | 45 - logger-logging - 1.0.0 | Error while Calling BPMN: org.activiti.engine.ActivitiIllegalArgumentException: Field definition uses unexisting field 'moduleName' on class Proxy8477823f_cf1d_4efb_8912_0b18301965d9
ActivitiIllegalArgumentException: Field definition uses unexisting field 'moduleName' on class Proxy8477823f_cf1d_4efb_8912_0b18301965d9
</blockcode>
i Use Version 5.19.3
