Running Camunda using Spring Boot

I am new to Camunda. I have some user tasks, once some of them are completed, I am triggering Service Task and its type is Java Delegate. The tasks are sequentially ordered Task 1, Task 2, Task 3 and Service Task. When I try to complete the Task 3 I am facing the below exception.

Exception Message - 500 : "{"type":"NoSuchMethodError","message":"'void org.camunda.bpm.engine.impl.interceptor.ContextLogger.log(java.lang.String, java.lang.String, java.lang.String, java.lang.Object[])'","code":null} 

BPMN model XML file

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_04pa98v" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.25.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.21.0">
  <bpmn:process id="Process_1vdkmyo" isExecutable="true" camunda:historyTimeToLive="180">
    <bpmn:startEvent id="StartEvent_1" name="start">
      <bpmn:outgoing>Flow_1t3m9zu</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_1t3m9zu" sourceRef="StartEvent_1" targetRef="Activity_0d7121y" />
    <bpmn:userTask id="Activity_0d7121y" name="Task 1">
      <bpmn:incoming>Flow_1t3m9zu</bpmn:incoming>
      <bpmn:outgoing>Flow_0715y5g</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:userTask id="Activity_153ylyy" name="Task 2">
      <bpmn:incoming>Flow_0715y5g</bpmn:incoming>
      <bpmn:outgoing>Flow_1kskpcw</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_0715y5g" sourceRef="Activity_0d7121y" targetRef="Activity_153ylyy" />
    <bpmn:sequenceFlow id="Flow_1kskpcw" sourceRef="Activity_153ylyy" targetRef="Activity_0rwsgpo" />
    <bpmn:userTask id="Activity_0rwsgpo" name="Task 3">
      <bpmn:incoming>Flow_1kskpcw</bpmn:incoming>
      <bpmn:outgoing>Flow_13xgynl</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_13xgynl" sourceRef="Activity_0rwsgpo" targetRef="Activity_012izt2" />
    <bpmn:serviceTask id="Activity_012izt2" name="Service Task" camunda:class="com.camunda.camunda_engine.delegate.RiskCheckAPIDelegate">
      <bpmn:incoming>Flow_13xgynl</bpmn:incoming>
      <bpmn:outgoing>Flow_1m2nycu</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_1m2nycu" sourceRef="Activity_012izt2" targetRef="Activity_0pj40u9" />
    <bpmn:userTask id="Activity_0pj40u9" name="Task 4">
      <bpmn:incoming>Flow_1m2nycu</bpmn:incoming>
      <bpmn:outgoing>Flow_1xguir5</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:exclusiveGateway id="Gateway_09m257y">
      <bpmn:incoming>Flow_1xguir5</bpmn:incoming>
      <bpmn:outgoing>Flow_13cthpc</bpmn:outgoing>
      <bpmn:outgoing>Flow_044spwv</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_1xguir5" sourceRef="Activity_0pj40u9" targetRef="Gateway_09m257y" />
    <bpmn:sequenceFlow id="Flow_13cthpc" name="Approved" sourceRef="Gateway_09m257y" targetRef="Activity_1t094gx">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${riskCheck == "Approved"}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:userTask id="Activity_1t094gx" name="Risk Approved Task">
      <bpmn:incoming>Flow_13cthpc</bpmn:incoming>
      <bpmn:outgoing>Flow_01gbx94</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_044spwv" name="Rejected" sourceRef="Gateway_09m257y" targetRef="Activity_1kl7104">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${riskCheck == "Rejected"}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:userTask id="Activity_1kl7104" name="Risk Reject Task">
      <bpmn:incoming>Flow_044spwv</bpmn:incoming>
      <bpmn:outgoing>Flow_13ks01q</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:exclusiveGateway id="Gateway_0zh50jt">
      <bpmn:incoming>Flow_01gbx94</bpmn:incoming>
      <bpmn:incoming>Flow_13ks01q</bpmn:incoming>
      <bpmn:outgoing>Flow_1y0e2n5</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_01gbx94" sourceRef="Activity_1t094gx" targetRef="Gateway_0zh50jt" />
    <bpmn:sequenceFlow id="Flow_13ks01q" sourceRef="Activity_1kl7104" targetRef="Gateway_0zh50jt" />
    <bpmn:endEvent id="Event_07s3sn7" name="end">
      <bpmn:incoming>Flow_1y0e2n5</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_1y0e2n5" sourceRef="Gateway_0zh50jt" targetRef="Event_07s3sn7" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1vdkmyo">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="186" y="142" width="23" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1fn80kl_di" bpmnElement="Activity_0d7121y">
        <dc:Bounds x="290" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_153ylyy_di" bpmnElement="Activity_153ylyy">
        <dc:Bounds x="470" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_13auu4p_di" bpmnElement="Activity_0rwsgpo">
        <dc:Bounds x="650" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1godgg5_di" bpmnElement="Activity_012izt2">
        <dc:Bounds x="790" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0zgyvg7_di" bpmnElement="Activity_0pj40u9">
        <dc:Bounds x="790" y="230" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_09m257y_di" bpmnElement="Gateway_09m257y" isMarkerVisible="true">
        <dc:Bounds x="665" y="245" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0omk8w3_di" bpmnElement="Activity_1t094gx">
        <dc:Bounds x="640" y="350" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0jhtmda_di" bpmnElement="Activity_1kl7104">
        <dc:Bounds x="470" y="230" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_0zh50jt_di" bpmnElement="Gateway_0zh50jt" isMarkerVisible="true">
        <dc:Bounds x="495" y="365" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_07s3sn7_di" bpmnElement="Event_07s3sn7">
        <dc:Bounds x="362" y="372" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="371" y="415" width="19" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_1t3m9zu_di" bpmnElement="Flow_1t3m9zu">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="290" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0715y5g_di" bpmnElement="Flow_0715y5g">
        <di:waypoint x="390" y="117" />
        <di:waypoint x="470" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1kskpcw_di" bpmnElement="Flow_1kskpcw">
        <di:waypoint x="570" y="117" />
        <di:waypoint x="650" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_13xgynl_di" bpmnElement="Flow_13xgynl">
        <di:waypoint x="750" y="117" />
        <di:waypoint x="790" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1m2nycu_di" bpmnElement="Flow_1m2nycu">
        <di:waypoint x="840" y="157" />
        <di:waypoint x="840" y="230" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1xguir5_di" bpmnElement="Flow_1xguir5">
        <di:waypoint x="790" y="270" />
        <di:waypoint x="715" y="270" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_13cthpc_di" bpmnElement="Flow_13cthpc">
        <di:waypoint x="690" y="295" />
        <di:waypoint x="690" y="350" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="682" y="320" width="47" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_044spwv_di" bpmnElement="Flow_044spwv">
        <di:waypoint x="665" y="270" />
        <di:waypoint x="570" y="270" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="597" y="252" width="44" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_01gbx94_di" bpmnElement="Flow_01gbx94">
        <di:waypoint x="640" y="390" />
        <di:waypoint x="545" y="390" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_13ks01q_di" bpmnElement="Flow_13ks01q">
        <di:waypoint x="520" y="310" />
        <di:waypoint x="520" y="365" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1y0e2n5_di" bpmnElement="Flow_1y0e2n5">
        <di:waypoint x="495" y="390" />
        <di:waypoint x="398" y="390" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Delegate Implementation for Service Task

package com.camunda.camunda_engine.delegate;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import com.company.shared.entity.ApplicationDetailsEntity;
import com.company.shared.model.RiskStatusRequestModel;
import com.company.shared.model.RiskStatusResponseModel;
import com.company.shared.repository.ApplicationRepository;

public class RiskCheckAPIDelegate implements JavaDelegate {
	
	@Autowired
	ApplicationRepository applicationRepository;
	
	@Autowired
	RestTemplate restTemplate;

	@Override
	public void execute(DelegateExecution execution) throws Exception {
		String apiUrl = "http://localhost:8082/riskStatus";
		
		//getting process variables
		String applicationId = (String) execution.getVariable("applicationId");
		ApplicationDetailsEntity applicationDetailsEntity = applicationRepository.findByApplicationId(applicationId);
		String riskCheckStatus = applicationDetailsEntity.getRiskCheckStatus();
		
		//Framing request Payload
		RiskStatusRequestModel requestPayload = new RiskStatusRequestModel();
        requestPayload.setApplicationId(applicationId);
        requestPayload.setRiskStatus(riskCheckStatus);
		
		// Set the headers for the request
        HttpHeaders headers = new HttpHeaders();
        headers.set("Content-Type", "application/json");
        
     // Create the request entity with the request model
        HttpEntity<RiskStatusRequestModel> requestEntity = new HttpEntity<>(requestPayload, headers);
		
     // Invoke the RiskCheck API and expect a RiskStatusResponseModel as the response
        ResponseEntity<RiskStatusResponseModel> responseEntity = restTemplate.exchange(apiUrl, HttpMethod.POST, requestEntity, RiskStatusResponseModel.class);
        
     // Parse the response
        RiskStatusResponseModel responseModel = responseEntity.getBody();
		
		
     // Extract the field from the response
        String riskStatus = responseModel.getRiskStatus();

        // Set the field value as a process variable
        execution.setVariable("riskStatus", riskStatus);
        
        
		
	}

}

Screenshot of Camunda BPMN Model

Please help me rectify this error.

Hello my friend!

Try doing it this way:

  • Put @Component on top of your delegate class name.
  • In your process workflow, change the implementation of your service task to “Delegate expression”, and in the field below do ${riskCheckAPIDelegate}

This should work and is the most recommended pattern nowadays than using Java Class.

like my example below:

image

I hope this helps!

William Robert Alves

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.