Hi, I am trying to use field injection on a JavaDelegate service and am having an issue with Spring where activiti is trying to get/set the field on the service object but Spring is proxying that object (via JdkDynamicAopProxy) and activiti can't find the field through the proxy.
The XML for the service task is defined as:
<serviceTask id="sid-123" name="Correlation1" activiti:delegateExpression="${correlationService}">
<extensionElements>
<activiti:field name="correlationName" stringValue="Correlation1"/>
</extensionElements>
</serviceTask>
Then the service task is defined as:
@Service
public class CorrelationService implements JavaDelegate {public Expression correlationName;@Override
public void execute(DelegateExecution execution) throws Exception {
// code omitted...
}
}
Now when that service task is activated in the activiti process, it gets hung up trying to pass that correlationName variable and throws the error listed below.
[ERROR] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.activiti.engine.ActivitiIllegalArgumentException: Field definition uses unexisting field 'correlationName' on class com.sun.proxy.$Proxy143] with root cause
org.activiti.engine.ActivitiIllegalArgumentException: Field definition uses unexisting field 'correlationName' on class com.sun.proxy.$Proxy143
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.applyFieldDeclaration(ClassDelegate.java:283) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.applyFieldDeclaration(ClassDelegate.java:256) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.helper.DelegateExpressionUtil.resolveDelegateExpression(DelegateExpressionUtil.java:43) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior.execute(ServiceTaskDelegateExpressionActivityBehavior.java:85) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:650) ~[activiti-engine-5.22.0.jar:5.22.0]....
Here's a couple debug screenshots showing where the proxy is in place of the actual object:
I believe it is being proxied as part of AoP in the Spring framework. Surely Activiti is compatible with Spring? Strangely enough, a unit test using a mocked rest object seems to not cause any problems, it's only when I run the full web application that the proxy issue is arising -- perhaps an artifact of the way Spring handles unit tests, I'm really not sure. Either way, this is a pretty basic Activiti use case that it seems hard to believe wouldn't be possible in conjunction with Spring. Maybe there is some kind of configuration issue or something?
Hi Brenden R ,
Interesting! We have used Java service task's field injection in actual web applications deployed on application server and we haven't seen this issue. From your description, it seems that you are implementing Spring AOP in your application. That actually makes sense as it sort of matches to the error you're having.
Field definition uses unexisting field 'correlationName' on class com.sun.proxy.$Proxy143] with root cause
Did your unit test include AOP parts as well? Perhaps you actually did create a proxy to intercept the java service task? Anyway, it's all wild guesses from me for now. It would be great if you can reproduce the issue within a unit test and share. If you use AOP, please try to include it to the unit test as well. Also, if you can share your beans.xml file, that would be useful as well.
Thanks,
Thong
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.