cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to call javadelegate class

surya
Champ in-the-making
Champ in-the-making
Hi,

I'm new to activiti. I have a created a stand-alone java application with simple process like[ Start->ServiceTask->End ]. Below are the files are using in sample application, Main.java, MyJavaDelegate.java & bpmn files. When running this application i'm getting below exception:

Exception:  [Validation set: 'activiti-executable-process' | Problem: 'activiti-servicetask-missing-implementation'] : One of the attributes 'class', 'delegateExpression', 'type', 'operation', or 'expression' is mandatory on serviceTask. - [Extra info : processDefinitionId = helloWorld | id = myServiceTask | ] ( line: 10, column: 92) ————-

I thought, i should register JavaDelegate class instance with ActivitiRuntimeEngine. Please suggest?

Below are the files:
——————————————————————————–
Main.java
——————————————————————————–
public class Main {
    public static void main(String[] args) throws ClassNotFoundException {
        try {
            // Create the Activiti engine in-memory on H2 database
            ProcessEngineConfiguration engineConfig = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
            ProcessEngine processEngine = engineConfig.buildProcessEngine();

            processEngine.getRepositoryService().createDeployment()
                    .addClasspathResource("hello-world.bpmn20.xml")
                    .deploy();
           
            ProcessInstance processInstance = processEngine.getRuntimeService()
                    .startProcessInstanceByKey("helloWorld");

            System.out.println("Process instance id:" + processInstance.getId());
           
            processEngine.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

——————————————————————————–
MyJavaDelegate.java . This files was placed in 'org.sample.delegates' package.
——————————————————————————–
public class MyJavaDelegate implements JavaDelegate {
   
   @Override
   public void execute(DelegateExecution execution) throws Exception {       
       System.out.println("Service task called…");
  }
}

——————————————————————————–
hello-world.bpmn20
——————————————————————————–
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:activiti="http://activiti.org/bpmn-extensions"
             targetNamespace="http://www.activiti.org/bpmn2.0">
 
  <process id="helloWorld"> 
    <startEvent id="theStart" />   
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="myServiceTask" />   
    <serviceTask id="myServiceTask" activiti:class="org.sample.delegates.MyJavaDelegate" />
    <sequenceFlow id="flow2" sourceRef="myServiceTask" targetRef="theEnd" />   
    <endEvent id="theEnd" />   
  </process>

</definitions>
3 REPLIES 3

surya
Champ in-the-making
Champ in-the-making
Hi, forget to attach process definition:

  <process id="helloWorld"> 
    <startEvent id="theStart" />   
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="myServiceTask" />   
    <serviceTask id="myServiceTask" activiti:class="org.sample.delegates.MyJavaDelegate" />
    <sequenceFlow id="flow2" sourceRef="myServiceTask" targetRef="theEnd" />   
    <endEvent id="theEnd" />   
  </process>

vasile_dirla
Star Contributor
Star Contributor
Hi,
You can start investigating it with a breakpoint in : ServiceTaskValidator.java on the method:
<code>
protected void verifyImplementation(Process process, ServiceTask serviceTask, List<ValidationError> errors)
</code>

Which version of Activiti are you using?

surya
Champ in-the-making
Champ in-the-making
At last, i figured out the issue. Problem is with activiti version. I'm using 5.19, in that, name space should be

"xmlns:activiti="http://activiti.org/bpmn".

@vasile.dirla: Thank you very much for quick help. You simply great Smiley Happy