我正在尝试在xml中获取源FlowTarget和目标FlowNode,并使用
byteArrayInputStream = new ByteArrayInputStream(input.getXml().getBytes(UTF8));
BpmnModelInstance modelInstance = Bpmn.readModelFromStream(byteArrayInputStream);
SequenceFlow sequenceFlow = modelInstance.getModelElementById("Task_12yh8ez");
FlowNode source = sequenceFlow.getSource();
FlowNode target = sequenceFlow.getTarget();
此方法会像这样出现异常;
CustomizedResponseEntityExceptionHandler : Exception Message: class org.camunda.bpm.model.bpmn.impl.instance.ServiceTaskImpl cannot be cast to class org.camunda.bpm.model.bpmn.instance.SequenceFlow (org.camunda.bpm.model.bpmn.impl.instance.ServiceTaskImpl and org.camunda.bpm.model.bpmn.instance.SequenceFlow are in unnamed module of loader ‘app’)
我的gradle配置;
org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter:3.3.1
org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp:3.3.1
org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-rest:3.3.1
我的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” id=“Definitions_1oqflw4” targetNamespace=“http://bpmn.io/schema/bpmn” exporter=“Camunda Modeler” exporterVersion=“2.2.4”>
<bpmn:process id=“ali” name=“veli”>
<bpmn:userTask id=“Task_0d5qo6i” name=“userTask”>
bpmn:outgoingSequenceFlow_092robg</bpmn:outgoing>
</bpmn:userTask>
<bpmn:businessRuleTask id=“Task_1neom7v” name=“businesssTask”>
bpmn:incomingSequenceFlow_0nwxzxk</bpmn:incoming>
</bpmn:businessRuleTask>
<bpmn:serviceTask id=“Task_12yh8ez” name=“servicetsak”>
bpmn:incomingSequenceFlow_092robg</bpmn:incoming>
bpmn:outgoingSequenceFlow_0nwxzxk</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id=“SequenceFlow_092robg” sourceRef=“Task_0d5qo6i” targetRef=“Task_12yh8ez” />
<bpmn:sequenceFlow id=“SequenceFlow_0nwxzxk” sourceRef=“Task_12yh8ez” targetRef=“Task_1neom7v” />
</bpmn:process>
<bpmndi:BPMNDiagram id=“BPMNDiagram_1”>
<bpmndi:BPMNPlane id=“BPMNPlane_1” bpmnElement=“ali”>
<bpmndi:BPMNShape id=“UserTask_02t5zlj_di” bpmnElement=“Task_0d5qo6i”>
<dc:Bounds x=“156” y=“205” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id=“BusinessRuleTask_1ekkayc_di” bpmnElement=“Task_1neom7v”>
<dc:Bounds x=“548” y=“205” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id=“ServiceTask_09y01s5_di” bpmnElement=“Task_12yh8ez”>
<dc:Bounds x=“354” y=“205” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id=“SequenceFlow_092robg_di” bpmnElement=“SequenceFlow_092robg”>
<di:waypoint x=“256” y=“245” />
<di:waypoint x=“354” y=“245” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“SequenceFlow_0nwxzxk_di” bpmnElement=“SequenceFlow_0nwxzxk”>
<di:waypoint x=“454” y=“245” />
<di:waypoint x=“548” y=“245” />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
我应该怎么做才能获得SequenceFlows?或我的代码有什么问题? 谢谢...