我正在尝试加载外部bmpn2文件并在Apache Karaf环境中运行它。这是bmpn2文件
<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.jboss.org/drools" xmlns="http://www.jboss.org/drools" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd" id="Definition" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes">
<bpmn2:itemDefinition id="ItemDefinition_3" structureRef="java.lang.String"/>
<bpmn2:itemDefinition id="_ItemDefinition_5210" structureRef="com.test.ToolsServicesTwo"/>
<bpmn2:message id="String" itemRef="ItemDefinition_3" name="String"/>
<bpmn2:interface id="Interface_4" implementationRef="com.test.ToolsServicesOne" name="com.test.ToolsServicesOne">
<bpmn2:operation id="_Operation_239" name="doService">
<bpmn2:inMessageRef>String</bpmn2:inMessageRef>
</bpmn2:operation>
</bpmn2:interface>
<bpmn2:interface id="Interface_5" implementationRef="com.test.ToolsServicesTwo" name="com.test.ToolsServicesTwo">
<bpmn2:operation id="_Operation_306" name="doService">
<bpmn2:inMessageRef>String</bpmn2:inMessageRef>
</bpmn2:operation>
</bpmn2:interface>
<bpmn2:process id="com.test.sample_process" tns:version="1" tns:packageName="com.test" tns:adHoc="false" name="sample_process" isExecutable="true" processType="Private">
<bpmn2:extensionElements>
<tns:import name="com.test.ToolsServicesOne"/>
<tns:import name="java.lang.String"/>
<tns:import name="com.test.ToolsServicesTwo"/>
</bpmn2:extensionElements>
<bpmn2:property id="toolsMessage" itemSubjectRef="ItemDefinition_3"/>
<bpmn2:startEvent id="StartEvent_1" name="StartProcess">
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:serviceTask id="ServiceTask_1" name="ToolsServiceOne" implementation="##WebService" operationRef="_Operation_239">
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
<bpmn2:ioSpecification id="InputOutputSpecification_3">
<bpmn2:dataInput id="DataInput_8" itemSubjectRef="ItemDefinition_3" name="Parameter"/>
<bpmn2:inputSet id="InputSet_1" name="Input Set 1">
<bpmn2:dataInputRefs>DataInput_8</bpmn2:dataInputRefs>
</bpmn2:inputSet>
<bpmn2:outputSet id="OutputSet_1" name="Output Set 1"/>
</bpmn2:ioSpecification>
<bpmn2:dataInputAssociation id="DataInputAssociation_4">
<bpmn2:sourceRef>toolsMessage</bpmn2:sourceRef>
<bpmn2:targetRef>DataInput_8</bpmn2:targetRef>
</bpmn2:dataInputAssociation>
</bpmn2:serviceTask>
<bpmn2:sequenceFlow id="SequenceFlow_1" tns:priority="1" name="" sourceRef="StartEvent_1" targetRef="ServiceTask_1"/>
<bpmn2:serviceTask id="ServiceTask_2" name="ToolsServiceTwo" implementation="##WebService" operationRef="_Operation_306">
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
<bpmn2:ioSpecification id="InputOutputSpecification_5">
<bpmn2:dataInput id="DataInput_9" itemSubjectRef="ItemDefinition_3" name="Parameter"/>
<bpmn2:inputSet id="InputSet_2" name="Input Set 2">
<bpmn2:dataInputRefs>DataInput_9</bpmn2:dataInputRefs>
</bpmn2:inputSet>
<bpmn2:outputSet id="OutputSet_2" name="Output Set 2"/>
</bpmn2:ioSpecification>
<bpmn2:dataInputAssociation id="DataInputAssociation_5">
<bpmn2:sourceRef>toolsMessage</bpmn2:sourceRef>
<bpmn2:targetRef>DataInput_9</bpmn2:targetRef>
</bpmn2:dataInputAssociation>
</bpmn2:serviceTask>
<bpmn2:sequenceFlow id="SequenceFlow_2" tns:priority="1" name="" sourceRef="ServiceTask_1" targetRef="ServiceTask_2"/>
<bpmn2:endEvent id="EndEvent_1" name="">
<bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow_3" tns:priority="1" name="" sourceRef="ServiceTask_2" targetRef="EndEvent_1"/>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="com.test.sample_process">
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="StartEvent_1">
<dc:Bounds height="0.0" width="0.0" x="45.0" y="45.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_ServiceTask_1" bpmnElement="ServiceTask_1">
<dc:Bounds height="50.0" width="110.0" x="186.0" y="38.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_ServiceTask_2" bpmnElement="ServiceTask_2">
<dc:Bounds height="50.0" width="110.0" x="401.0" y="38.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="579.0" y="45.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_ServiceTask_1">
<di:waypoint xsi:type="dc:Point" x="81.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="128.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="128.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="186.0" y="63.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="BPMNShape_ServiceTask_1" targetElement="BPMNShape_ServiceTask_2">
<di:waypoint xsi:type="dc:Point" x="296.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="343.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="343.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="401.0" y="63.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="BPMNShape_ServiceTask_2" targetElement="BPMNShape_EndEvent_1">
<di:waypoint xsi:type="dc:Point" x="511.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="541.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="541.0" y="63.0"/>
<di:waypoint xsi:type="dc:Point" x="579.0" y="63.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
以下是用于启动工作流程的代码
File file = new File(workflowFile);
if(file == null || !file.exists()) {
throw new FileNotFoundException("Specified file path is invalid.");
}
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getEmpty()
.addAsset(ResourceFactory.newFileResource(file ), ResourceType.BPMN2)
.get();
RuntimeManager manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
ksession.startProcess(processId);
System.out.println("Proc started!");
其中,workflowFile
表示某些目录中保存的bpmn2文件的绝对URL。当我在Karaf(As bundle activator或Karaf命令扩展)上运行此代码时,我收到以下错误
java.lang.IllegalArgumentException: Cannot add asset: Error importing : 'com.test.ToolsServicesOne',Error importing : 'com.test.ToolsServicesTwo',
at org.jbpm.runtime.manager.impl.SimpleRuntimeEnvironment.addAsset(SimpleRuntimeEnvironment.java:111)
at org.jbpm.runtime.manager.impl.RuntimeEnvironmentBuilder.addAsset(RuntimeEnvironmentBuilder.java:341)
注意 如果我运行与简单JUnit测试相同的类,我不会收到任何错误
任何人都可以帮我解决这个问题吗?我尝试搜索谷歌/ JBPM论坛,但找不到任何解决方案。感谢您在这个帖子上的时间!