Camunda:如何解决 Play 框架应用程序中 JavaDelegate 进程的 ENGINE-09017 错误?
Camunda : How to solve ENGINE-09017 Error for JavaDelegate process in Play Framework Application?
我尝试在 PLay2 应用程序中嵌入一个 camunda 进程。但是当我启动 activity.
时,我得到了 ENGINE-09017 和 ENGINE-09008
我的测试步骤:
- 启动流程实例 => 确定
- 完成 "Approve Loan" 任务 => 完成 OK
- 自动启动 "javaTask" => 失败并出现错误 ENGINE-09008
play.api.http.HttpErrorHandlerExceptions$$anon: Execution exception[[ProcessEngineException: ENGINE-09008 Exception while instantiating class 'controllers.ProcessRequestDelegate': ENGINE-09017 Cannot load class 'controllers.ProcessRequestDelegate': controllers.Pr
ocessRequestDelegate]]
你能帮我找出问题所在吗?
此致
听听我的样本 java 委托人:
package controllers;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import play.Logger;
public class ProcessRequestDelegate implements JavaDelegate {
public ProcessRequestDelegate(){
}
@Override
public void execute(DelegateExecution execution) throws Exception {
Integer amount = (Integer)execution.getVariable("amount");
Logger.info("Processing loan approval for amount "+amount+"...");
}
}
我的启动引擎模块和处理程序:
public class StartUpHandler{
private final ProcessEngineConfiguration conf;
private final ProcessEngine engine;
private final DeploymentBuilder deployment;
public StartUpHandler() {
conf = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
.setJdbcDriver("org.h2.Driver")
.setJdbcUrl("jdbc:h2:file:D:/testLoan")
.setJdbcUsername("camunda")
.setJdbcPassword("camunda")
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setHistory(ProcessEngineConfiguration.HISTORY_FULL)
.setJobExecutorActivate(true);
Logger.info("Starting process engine...");
engine = conf.buildProcessEngine();
Logger.info("Deploying process definition...");
deployment = engine.getRepositoryService().createDeployment();
deployment.addClasspathResource("loan-approval.bpmn").enableDuplicateFiltering(true);
deployment.deploy();
}
}
-------------------------------------------- ----------
import com.google.inject.AbstractModule;
import controllers.StartUpHandler;
import java.time.Clock;
public class StartUpModule extends AbstractModule{
@Override
protected void configure() {
bind(StartUpHandler.class).asEagerSingleton();
}
}
和我的 BPMN 文件:
<?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: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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:tns="http://bpmn.io/schema/bpmn" xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="Definitions_1" name="" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
<bpmn:process id="approve-loan" name="Loan Approval Updated" processType="None" isClosed="false" isExecutable="true">
<bpmn:extensionElements>
<camunda:properties>
<camunda:property name="loanAmount" />
</camunda:properties>
</bpmn:extensionElements>
<bpmn:startEvent id="StartEvent_1" name="Loan Request Received" />
<bpmn:sequenceFlow id="SequenceFlow_0c4zr6d" sourceRef="StartEvent_1" targetRef="UserTask_11fud4o" />
<bpmn:userTask id="UserTask_11fud4o" name="Approve Loan" activiti:exclusive="true">
<bpmn:dataOutputAssociation id="DataOutputAssociation_105oy6a">
<bpmn:targetRef>loanApprovalDS</bpmn:targetRef>
</bpmn:dataOutputAssociation>
</bpmn:userTask>
<bpmn:endEvent id="EndEvent_1i5bz86" name="Loan Request Approved">
<bpmn:incoming>SequenceFlow_1vf0nn5</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1y4c0rn" sourceRef="UserTask_11fud4o" targetRef="javaTask" />
<bpmn:dataStoreReference id="loanApprovalDS" name="Loan Approval DS" />
<bpmn:sequenceFlow id="SequenceFlow_1vf0nn5" sourceRef="javaTask" targetRef="EndEvent_1i5bz86" />
<bpmn:serviceTask id="javaTask" name="javaTask" camunda:class="controllers.ProcessRequestDelegate">
<bpmn:incoming>SequenceFlow_1y4c0rn</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1vf0nn5</bpmn:outgoing>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="Diagram-_1" name="New Diagram" documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0">
<bpmndi:BPMNPlane bpmnElement="approve-loan">
<bpmndi:BPMNShape id="Shape-StartEvent_1" bpmnElement="StartEvent_1">
<dc:Bounds x="95" y="140" width="32" height="32" />
<bpmndi:BPMNLabel>
<dc:Bounds x="0" y="93" width="70" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Shape-UserTask_11fud4o" bpmnElement="UserTask_11fud4o">
<dc:Bounds x="146" y="63" width="100" height="80" />
<bpmndi:BPMNLabel>
<dc:Bounds x="0" y="0" width="100" height="80" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Shape-EndEvent_1i5bz86" bpmnElement="EndEvent_1i5bz86">
<dc:Bounds x="543" y="79" width="32" height="32" />
<bpmndi:BPMNLabel>
<dc:Bounds x="178" y="-23" width="70" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1y4c0rn" bpmnElement="SequenceFlow_1y4c0rn" sourceElement="Shape-UserTask_11fud4o" targetElement="ServiceTask_0ieswob_di">
<di:waypoint x="246" y="86" />
<di:waypoint x="356" y="95" />
<bpmndi:BPMNLabel>
<dc:Bounds x="369" y="110" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_0c4zr6d" bpmnElement="SequenceFlow_0c4zr6d" sourceElement="StartEvent_1" targetElement="UserTask_11fud4o">
<di:waypoint x="111" y="140" />
<di:waypoint x="111" y="43" />
<di:waypoint x="196" y="43" />
<di:waypoint x="196" y="63" />
<bpmndi:BPMNLabel>
<dc:Bounds x="198.5" y="110" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="DataStoreReference_15u5ist_di" bpmnElement="loanApprovalDS">
<dc:Bounds x="339" y="255" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="320" y="308" width="90" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="DataOutputAssociation_105oy6a_di" bpmnElement="DataOutputAssociation_105oy6a">
<di:waypoint x="232" y="143" />
<di:waypoint x="339" y="263" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1vf0nn5_di" bpmnElement="SequenceFlow_1vf0nn5">
<di:waypoint x="456" y="99" />
<di:waypoint x="545" y="103" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_0ieswob_di" bpmnElement="javaTask">
<dc:Bounds x="356" y="55" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
我已经通过将播放类加载器添加到 ProcessEngine 实例解决了我的问题:
conf = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
.setJdbcDriver("org.h2.Driver")
.setJdbcUrl("jdbc:h2:file:D:/testLoan")
.setJdbcUsername("camunda")
.setJdbcPassword("camunda")
.setClassLoader(StartUpHandler.class.getClassLoader())
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setHistory(ProcessEngineConfiguration.HISTORY_FULL)
.setJobExecutorActivate(true);
我尝试在 PLay2 应用程序中嵌入一个 camunda 进程。但是当我启动 activity.
时,我得到了 ENGINE-09017 和 ENGINE-09008我的测试步骤: - 启动流程实例 => 确定 - 完成 "Approve Loan" 任务 => 完成 OK - 自动启动 "javaTask" => 失败并出现错误 ENGINE-09008
play.api.http.HttpErrorHandlerExceptions$$anon: Execution exception[[ProcessEngineException: ENGINE-09008 Exception while instantiating class 'controllers.ProcessRequestDelegate': ENGINE-09017 Cannot load class 'controllers.ProcessRequestDelegate': controllers.Pr ocessRequestDelegate]]
你能帮我找出问题所在吗?
此致
听听我的样本 java 委托人:
package controllers;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import play.Logger;
public class ProcessRequestDelegate implements JavaDelegate {
public ProcessRequestDelegate(){
}
@Override
public void execute(DelegateExecution execution) throws Exception {
Integer amount = (Integer)execution.getVariable("amount");
Logger.info("Processing loan approval for amount "+amount+"...");
}
}
我的启动引擎模块和处理程序:
public class StartUpHandler{
private final ProcessEngineConfiguration conf;
private final ProcessEngine engine;
private final DeploymentBuilder deployment;
public StartUpHandler() {
conf = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
.setJdbcDriver("org.h2.Driver")
.setJdbcUrl("jdbc:h2:file:D:/testLoan")
.setJdbcUsername("camunda")
.setJdbcPassword("camunda")
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setHistory(ProcessEngineConfiguration.HISTORY_FULL)
.setJobExecutorActivate(true);
Logger.info("Starting process engine...");
engine = conf.buildProcessEngine();
Logger.info("Deploying process definition...");
deployment = engine.getRepositoryService().createDeployment();
deployment.addClasspathResource("loan-approval.bpmn").enableDuplicateFiltering(true);
deployment.deploy();
}
}
-------------------------------------------- ----------
import com.google.inject.AbstractModule;
import controllers.StartUpHandler;
import java.time.Clock;
public class StartUpModule extends AbstractModule{
@Override
protected void configure() {
bind(StartUpHandler.class).asEagerSingleton();
}
}
和我的 BPMN 文件:
<?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: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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:tns="http://bpmn.io/schema/bpmn" xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="Definitions_1" name="" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
<bpmn:process id="approve-loan" name="Loan Approval Updated" processType="None" isClosed="false" isExecutable="true">
<bpmn:extensionElements>
<camunda:properties>
<camunda:property name="loanAmount" />
</camunda:properties>
</bpmn:extensionElements>
<bpmn:startEvent id="StartEvent_1" name="Loan Request Received" />
<bpmn:sequenceFlow id="SequenceFlow_0c4zr6d" sourceRef="StartEvent_1" targetRef="UserTask_11fud4o" />
<bpmn:userTask id="UserTask_11fud4o" name="Approve Loan" activiti:exclusive="true">
<bpmn:dataOutputAssociation id="DataOutputAssociation_105oy6a">
<bpmn:targetRef>loanApprovalDS</bpmn:targetRef>
</bpmn:dataOutputAssociation>
</bpmn:userTask>
<bpmn:endEvent id="EndEvent_1i5bz86" name="Loan Request Approved">
<bpmn:incoming>SequenceFlow_1vf0nn5</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1y4c0rn" sourceRef="UserTask_11fud4o" targetRef="javaTask" />
<bpmn:dataStoreReference id="loanApprovalDS" name="Loan Approval DS" />
<bpmn:sequenceFlow id="SequenceFlow_1vf0nn5" sourceRef="javaTask" targetRef="EndEvent_1i5bz86" />
<bpmn:serviceTask id="javaTask" name="javaTask" camunda:class="controllers.ProcessRequestDelegate">
<bpmn:incoming>SequenceFlow_1y4c0rn</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1vf0nn5</bpmn:outgoing>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="Diagram-_1" name="New Diagram" documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0">
<bpmndi:BPMNPlane bpmnElement="approve-loan">
<bpmndi:BPMNShape id="Shape-StartEvent_1" bpmnElement="StartEvent_1">
<dc:Bounds x="95" y="140" width="32" height="32" />
<bpmndi:BPMNLabel>
<dc:Bounds x="0" y="93" width="70" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Shape-UserTask_11fud4o" bpmnElement="UserTask_11fud4o">
<dc:Bounds x="146" y="63" width="100" height="80" />
<bpmndi:BPMNLabel>
<dc:Bounds x="0" y="0" width="100" height="80" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Shape-EndEvent_1i5bz86" bpmnElement="EndEvent_1i5bz86">
<dc:Bounds x="543" y="79" width="32" height="32" />
<bpmndi:BPMNLabel>
<dc:Bounds x="178" y="-23" width="70" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1y4c0rn" bpmnElement="SequenceFlow_1y4c0rn" sourceElement="Shape-UserTask_11fud4o" targetElement="ServiceTask_0ieswob_di">
<di:waypoint x="246" y="86" />
<di:waypoint x="356" y="95" />
<bpmndi:BPMNLabel>
<dc:Bounds x="369" y="110" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_0c4zr6d" bpmnElement="SequenceFlow_0c4zr6d" sourceElement="StartEvent_1" targetElement="UserTask_11fud4o">
<di:waypoint x="111" y="140" />
<di:waypoint x="111" y="43" />
<di:waypoint x="196" y="43" />
<di:waypoint x="196" y="63" />
<bpmndi:BPMNLabel>
<dc:Bounds x="198.5" y="110" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="DataStoreReference_15u5ist_di" bpmnElement="loanApprovalDS">
<dc:Bounds x="339" y="255" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="320" y="308" width="90" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="DataOutputAssociation_105oy6a_di" bpmnElement="DataOutputAssociation_105oy6a">
<di:waypoint x="232" y="143" />
<di:waypoint x="339" y="263" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1vf0nn5_di" bpmnElement="SequenceFlow_1vf0nn5">
<di:waypoint x="456" y="99" />
<di:waypoint x="545" y="103" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_0ieswob_di" bpmnElement="javaTask">
<dc:Bounds x="356" y="55" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
我已经通过将播放类加载器添加到 ProcessEngine 实例解决了我的问题:
conf = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
.setJdbcDriver("org.h2.Driver")
.setJdbcUrl("jdbc:h2:file:D:/testLoan")
.setJdbcUsername("camunda")
.setJdbcPassword("camunda")
.setClassLoader(StartUpHandler.class.getClassLoader())
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setHistory(ProcessEngineConfiguration.HISTORY_FULL)
.setJobExecutorActivate(true);