02-11-2019 07:38 PM
Hi All,
I am trying to implement a simple java class for process serviceTask from kickstart app, my ultimate goal to use this class for stencils.
I was able to create a app with input from with takes two numbers and serviceTask to add both numbers and
returns result.
I used 9.0.16, java 8, activiti 6.0.0
When my serviceTask trys to call java application for processing which is on tomcat lib it is throwing exception.
org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [appDispatcher] in context with path [/activiti-app]
threw exception [Request processing failed; nested exception is org.activiti.engine.ActivitiIllegalArgumentException: org.activiti.BasicAdditionDelegate
doesn't implement org.activiti.engine.delegate.JavaDelegate nor org.activiti.engine.impl.delegate.ActivityBehavior] with root cause
org.activiti.engine.ActivitiIllegalArgumentException: org.activiti.BasicAdditionDelegate doesn't implement org.activiti.engine.delegate.JavaDelegate
nor org.activiti.engine.impl.delegate.ActivityBehavior
My java class looks as below
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
public class BasicAdditionDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) {
System.out.println("Inside execution ");
System.out.println(execution.getVariableNames());
System.out.println(execution.getVariables());
int firstOperandNumber = Integer.valueOf((String) execution.getVariable("firstOperand"));
int secondOperandNumber = Integer.valueOf((String) execution.getVariable("SecondOperand"));
int result = Math.addExact(firstOperandNumber, secondOperandNumber);
execution.setVariable("targetProcessVariable", String.valueOf(result));
}
}
Thanks in advance for any recommendations.
02-12-2019 09:54 AM
From a quick look the only differences I can see with my service tasks is that the execute() method throws Execption and explicitly returns, i.e.
public void execute(DelegateExecution e) throws Exception {
.....
return;
}
02-12-2019 10:33 AM
Thanks, PaulT _ for your inputs.
I tried with adding "throws Exception" but no luck with the same error.
and "return" method return type is void, do we have to add a return.
I never thought of adding a return to this method.
Do you think that may cause?
02-12-2019 12:31 PM
No I wouldn't have really thought either of those things would be the cause of the problem, but they were the only obvious differences I could see between my service tasks that work - so thought worth mentioning. I'm using the Java API directly in Activiti 5.22.
02-12-2019 01:27 PM
Hmmm. I am using Activiti 6.0.0.
One thing I observed with 6.0 is no longer required to throws Exception.
Only thing I think of now is a version difference. Let me try with 5.22 and see how it goes.
Explore our Alfresco products with the links below. Use labels to filter content by product module.