完成用户任务时遇到异常(当下一个任务是使用 Java 委托的服务任务时)

问题描述 投票:0回答:1

我是卡蒙达的新手。我有一些用户任务,一旦其中一些任务完成,我就会触发服务任务,其类型是Java Delegate。这些任务按顺序排列为任务 1、任务 2、任务 3 和服务任务。当我尝试完成任务 3 时,我面临以下异常。

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 模型 XML 文件

<?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>

服务任务的委托实施

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);
        
        
        
    }

}

Camunda BPMN模型截图 enter image description here

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.3.2</version>
    <relativePath/>
</parent>

<groupId>com.camunda</groupId>
<artifactId>camunda-engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>camunda-engine</name>

<properties>
    <java.version>17</java.version>
</properties>

<dependencies>
    <!-- Spring Boot Web Starter -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- Camunda BPM Spring Boot Starter -->
    <dependency>
        <groupId>org.camunda.bpm.springboot</groupId>
        <artifactId>camunda-bpm-spring-boot-starter</artifactId>
        <version>7.20.0</version>
    </dependency>
    <dependency>
        <groupId>org.camunda.bpm.springboot</groupId>
        <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
        <version>7.20.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
    </dependency>
    <!-- Database (H2 for example) -->
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <!-- Lombok (Optional) -->
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <!-- Test Dependency -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.company</groupId>
        <artifactId>shared</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>central</id>
        <url>https://repo.maven.apache.org/maven2</url>
    </repository>
</repositories>
camunda bpmn camunda-modeler flowable
1个回答
0
投票

看这里: https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/version-compatibility/

Camunda 7.20 与 Spring Boot 3.3.x 不兼容。 降级到 Spring Boot 3.2.x 或将 Camunda 升级到 7.21。

© www.soinside.com 2019 - 2024. All rights reserved.