Spring Boot+Gradle集成Camunda HTTP Connector启动报错求助
问题:Camunda HTTP Connector集成启动报错
报错信息
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngineFactoryBean': FactoryBean threw exception on object creation; nested exception is org.camunda.bpm.engine.ParseException: ENGINE-09005 Could not parse BPMN process. Errors:
- One of the attributes 'class', 'delegateExpression', 'type', or 'expression' is mandatory on serviceTask. If you are using a connector, make sure the connect process engine plugin is registered with the process engine. | resource some-path\test.bpmn | line 27 | column 46
项目基于Spring Boot + Gradle,集成Camunda HTTP Connector后构建正常,但启动时抛出上述异常。以下是相关配置文件:
build.gradle 内容
buildscript { dependencies { classpath 'org.yaml:snakeyaml:1.26' } } plugins { id 'org.springframework.boot' version '2.5.8' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'java' id "org.liquibase.gradle" version "2.0.2" id 'jacoco' } group = 'some-group' version = '0.0.1-SNAPSHOT' sourceCompatibility = 11 targetCompatibility = 11 repositories { //mavenCentral() maven { url "some-url" } } ext { sentryVersion = '5.3.0' } test { finalizedBy jacocoTestReport } jacocoTestReport { reports { xml.enabled true html.enabled true csv.enabled false } } dependencies { // ==== Spring dependencies ==== implementation "org.springframework.boot:spring-boot-starter-web" implementation "org.springframework.boot:spring-boot-starter-data-jpa" // Sentry implementation "io.sentry:sentry-logback:$sentryVersion" // implementation 'org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-rest:7.17.0' implementation 'org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp:7.15.0' implementation 'org.camunda.bpm.extension:camunda-bpm-identity-keycloak:7.15.0' // implementation 'org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter:7.15.0' // https://mvnrepository.com/artifact/org.camunda.bpm.springboot/camunda-bpm-spring-boot-starter-rest implementation 'org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-rest:7.19.0' // https://mvnrepository.com/artifact/org.camunda.bpm/camunda-engine-plugin-connect // implementation 'org.camunda.bpm:camunda-engine-plugin-connect:7.20.0-alpha2' // implementation 'com.nimbusds:oauth2-oidc-sdk:9.12' implementation 'org.springframework.boot:spring-boot-starter-security' // implementation 'org.camunda.bpm.extension:camunda-platform-7-keycloak:7.17.0' implementation 'org.keycloak:keycloak-spring-boot-starter:15.0.2' // implementation 'org.springframework.security:spring-security-oauth2-core:5.5.1' implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.6.2' implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' implementation 'org.slf4j:slf4j-api:1.7.32' implementation 'ch.qos.logback:logback-classic:1.2.5' implementation 'org.keycloak:keycloak-core:21.1.1' implementation 'org.camunda.bpm.extension:camunda-bpm-identity-keycloak:2.2.3' // Camunda Connector implementation 'org.camunda.connect:camunda-connect-http-client:1.3.0' implementation 'org.camunda.connect:camunda-connect-soap-http-client:1.3.0' implementation 'org.camunda.connect:camunda-connect-core:1.1.0' implementation 'org.camunda.bpm:camunda-engine:7.15.0' implementation 'org.camunda.spin:camunda-spin-core:1.9.0' implementation 'org.camunda.spin:camunda-spin-dataformat-json-jackson:1.9.0' implementation 'org.camunda.spin:camunda-spin-dataformat-xml-dom:1.9.0' implementation 'org.camunda.bpm:camunda-engine-plugin-spin:7.15.0' implementation 'org.camunda.bpm:camunda-bom:7.15.0' implementation 'org.camunda.bpm.dmn:camunda-engine-dmn-bom:7.15.0' implementation 'org.camunda.connect:camunda-connect-connectors-all:1.0.0' implementation 'org.camunda.bpm:camunda-engine-plugin-connect:7.15.0' // Postgres JDBC runtimeOnly 'org.postgresql:postgresql' runtimeOnly 'com.h2database:h2' runtimeOnly 'com.sun.xml.bind:jaxb-impl:2.2.3' // Lombok implementation "org.projectlombok:lombok" annotationProcessor "org.projectlombok:lombok" implementation "org.keycloak:keycloak-admin-client:13.0.0" } def appProperties = new org.yaml.snakeyaml.Yaml().load(file("src/main/resources/application-local.yml").newInputStream()) def liquibaseProperties = new org.yaml.snakeyaml.Yaml().load(file("src/main/resources/liquibase.yaml").newInputStream()) diffChangeLog.dependsOn assemble //liquibase { // activities { // main { // changeLogFile "src/main/resources/db/changelog/changes/V" + migrationNumber() + "_changelog.yaml" // referenceUrl 'hibernate:spring:' + liquibaseProperties.getAt("entities-package-path") + '?dialect=' + liquibaseProperties.dialect // url appProperties.spring.datasource.url // username appProperties.spring.datasource.username // password appProperties.spring.datasource.password // driver liquibaseProperties.driver // } // } //} static def migrationNumber() { def files = new File("src/main/resources/db/changelog/changes") .listFiles(); if (files == null) return 0 return files.size(); } jar { enabled = true }
BPMN流程文件内容
<?xml version="1.0" encoding="UTF-8"?> <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_1bTwQUkWEeO-QfaFiKQ6Gw" targetNamespace="http://camunda.org/examples" exporter="Camunda Modeler" exporterVersion="5.15.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:message id="Message_3a4udev" name="Message_3a4udev" /> <bpmn2:process id="CAMT_Management_Workflow_V1.0" name="CAMT_Management_Workflow_V1.0" isExecutable="true"> <bpmn2:scriptTask id="scriptTask" name="Welcome Message" scriptFormat="groovy"> <bpmn2:extensionElements> <camunda:inputOutput> <camunda:inputParameter name="player"> <camunda:script scriptFormat="groovy"> players = ["Fritz", "Heinz", "Horst", "Klaus"] players[new Random().nextInt(players.size())] </camunda:script> </camunda:inputParameter> </camunda:inputOutput> </bpmn2:extensionElements> <bpmn2:script> println "Hello $player! Welcome to our casino" </bpmn2:script> </bpmn2:scriptTask> <bpmn2:endEvent id="Event_0ze79i7"> <bpmn2:incoming>Flow_16h5tsc</bpmn2:incoming> </bpmn2:endEvent> <bpmn2:startEvent id="Event_0dillfr"> <bpmn2:outgoing>Flow_0vfmd2r</bpmn2:outgoing> </bpmn2:startEvent> <bpmn2:sequenceFlow id="Flow_0vfmd2r" sourceRef="Event_0dillfr" targetRef="Activity_0vcor0x" /> <bpmn2:serviceTask id="Activity_0vcor0x"> <bpmn2:extensionElements> <camunda:connector> <camunda:inputOutput> <camunda:inputParameter name="method">POST</camunda:inputParameter> <camunda:inputParameter name="payload">{ "assessmentRequestId": "CA-2309-03858", "emailType": "EMAIL_FOR_ASSESSMENT_UPDATE" }</camunda:inputParameter> <camunda:inputParameter name="url">http://localhost:8180/email/send-email</camunda:inputParameter> </camunda:inputOutput> <camunda:connectorId>http-connector</camunda:connectorId> </camunda:connector> </bpmn2:extensionElements> <bpmn2:incoming>Flow_0vfmd2r</bpmn2:incoming> <bpmn2:outgoing>Flow_16h5tsc</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:sequenceFlow id="Flow_16h5tsc" sourceRef="Activity_0vcor0x" targetRef="Event_0ze79i7" /> </bpmn2:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CAMT_Management_Workflow_V1.0"> <bpmndi:BPMNShape id="Event_0dillfr_di" bpmnElement="Event_0dillfr"> <dc:Bounds x="152" y="82" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0ok0d83_di" bpmnElement="Activity_0vcor0x"> <dc:Bounds x="340" y="70" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_0ze79i7_di" bpmnElement="Event_0ze79i7"> <dc:Bounds x="602" y="102" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="Flow_0vfmd2r_di" bpmnElement="Flow_0vfmd2r"> <di:waypoint x="188" y="100" /> <di:waypoint x="259" y="100" /> <di:waypoint x="259" y="110" /> <di:waypoint x="340" y="110" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_16h5tsc_di" bpmnElement="Flow_16h5tsc"> <di:waypoint x="440" y="110" /> <di:waypoint x="526" y="110" /> <di:waypoint x="526" y="120" /> <di:waypoint x="602" y="120" /> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions>
解决方案
1. 统一Camunda版本依赖
你的build.gradle中存在版本不一致问题:
- Camunda webapp starter用的是7.15.0,但rest starter用的是7.19.0
- Keycloak相关依赖版本混乱(15.0.2、21.1.1、13.0.0)
统一所有Camunda相关依赖为7.15.0:
// 替换现有Camunda相关依赖为统一版本 implementation 'org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp:7.15.0' implementation 'org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-rest:7.15.0' implementation 'org.camunda.bpm.extension:camunda-bpm-identity-keycloak:7.15.0' implementation 'org.camunda.bpm:camunda-engine:7.15.0' implementation 'org.camunda.spin:camunda-spin-core:1.9.0' implementation 'org.camunda.spin:camunda-spin-dataformat-json-jackson:1.9.0' implementation 'org.camunda.spin:camunda-spin-dataformat-xml-dom:1.9.0' implementation 'org.camunda.bpm:camunda-engine-plugin-spin:7.15.0' implementation 'org.camunda.bpm:camunda-bom:7.15.0' implementation 'org.camunda.bpm.dmn:camunda-engine-dmn-bom:7.15.0' implementation 'org.camunda.connect:camunda-connect-core:1.3.0' implementation 'org.camunda.connect:camunda-connect-http-client:1.3.0' implementation 'org.camunda.connect:camunda-connect-soap-http-client:1.3.0' implementation 'org.camunda.connect:camunda-connect-connectors-all:1.3.0' implementation 'org.camunda.bpm:camunda-engine-plugin-connect:7.15.0'
同时统一Keycloak版本为与Camunda兼容的15.0.2:
implementation 'org.keycloak:keycloak-spring-boot-starter:15.0.2' implementation 'org.keycloak:keycloak-core:15.0.2' implementation 'org.keycloak:keycloak-admin-client:15.0.2'
2. 注册Connect插件到流程引擎
在Spring Boot配置类中显式注册Connect插件:
import org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class CamundaConfig { @Bean public ConnectProcessEnginePlugin connectProcessEnginePlugin() { return new ConnectProcessEnginePlugin(); } }
或者在application.yml中添加配置:
camunda: bpm: generic-properties: properties: processEnginePlugins: - class: org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin
3. 清理依赖并重新构建
执行以下Gradle命令清理并重新构建项目:
./gradlew clean build
验证
启动项目后,检查流程引擎是否成功加载BPMN文件,HTTP Connector服务任务是否能正常执行。
内容的提问来源于stack exchange,提问作者Abdollah Sobhy
相关产品推荐
相关产品推荐

