Could not parse knowledge. It is that the process definition is invalid or a bug of JBPM5.2
luhong Jan 11, 2012 3:11 AMHi,
I defined a process using bpmn2 visual editor according to JBPM5.2's sample.
Java Code:
package com.test.workflow; import org.drools.KnowledgeBase; import org.drools.builder.KnowledgeBuilder; import org.drools.builder.KnowledgeBuilderFactory; import org.drools.builder.ResourceType; import org.drools.io.ResourceFactory; import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.process.ProcessInstance; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; public class BPMN2Test { public static void main(String[] args) { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource("com/test/workflow/flow/eventBasedSplit.bpmn"), ResourceType.BPMN2); KnowledgeBase kbase = kbuilder.newKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); ksession.getWorkItemManager().registerWorkItemHandler("startNotifyEmail", new SystemOutWorkItemHandler()); ksession.getWorkItemManager().registerWorkItemHandler("endNotifyEmail", new SystemOutWorkItemHandler()); // Yes ProcessInstance processInstance = ksession.startProcess("com.sample.test"); ksession.getWorkItemManager().registerWorkItemHandler("startNotifyEmail", new SystemOutWorkItemHandler()); ksession.getWorkItemManager().registerWorkItemHandler("endNotifyEmail", new SystemOutWorkItemHandler()); ksession.signalEvent("Yes", "YesValue", processInstance.getId()); // No processInstance = ksession.startProcess("com.sample.test"); ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); ksession.signalEvent("No", "NoValue", processInstance.getId()); } }
BPMN2 file:
<?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:drools="http://www.jboss.org/drools" id="Definitions_1"> <bpmn2:process id="com.sample.test" name="Test" isExecutable="true"> <bpmn2:startEvent id="startEvent" name="Start"> <bpmn2:outgoing>startFlow</bpmn2:outgoing> </bpmn2:startEvent> <bpmn2:sequenceFlow id="startFlow" name="startFlow" sourceRef="startEvent" targetRef="startNotifyEmail"/> <bpmn2:task id="startNotifyEmail" drools:taskName="Email1" name="startNotifyEmail"> <bpmn2:incoming>startFlow</bpmn2:incoming> <bpmn2:outgoing>processSplitInFlow</bpmn2:outgoing> <bpmn2:ioSpecification id="startNotifyEmail"> <bpmn2:inputSet id="startNotifyInput" name="startNotifyInput"/> <bpmn2:outputSet id="startNotifyOutput" name="startNotifyOutput"/> </bpmn2:ioSpecification> </bpmn2:task> <bpmn2:sequenceFlow id="processSplitInFlow" name="processSplitInFlow" sourceRef="startNotifyEmail" targetRef="splitGateWay"/> <bpmn2:eventBasedGateway id="splitGateWay" name="splitGateWay" gatewayDirection="Diverging"> <bpmn2:incoming>processSplitInFlow</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> </bpmn2:eventBasedGateway> <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1" name="event"> <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> <bpmn2:dataOutput id="DataOutput_1" name="event"/> <bpmn2:dataOutputAssociation id="DataOutputAssociation_1"> <bpmn2:sourceRef>DataOutput_1</bpmn2:sourceRef> <bpmn2:targetRef>x</bpmn2:targetRef> </bpmn2:dataOutputAssociation> <bpmn2:outputSet id="OutputSet_2" name="OutputSet_2"> <bpmn2:dataOutputRefs>DataOutput_1</bpmn2:dataOutputRefs> </bpmn2:outputSet> <bpmn2:signalEventDefinition id="yes"/> <bpmn2:eventDefinitionRef>yes</bpmn2:eventDefinitionRef> </bpmn2:intermediateCatchEvent> <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_2" name="event2"> <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_12</bpmn2:outgoing> <bpmn2:dataOutput id="DataOutput_4" name="event2"/> <bpmn2:dataOutputAssociation id="DataOutputAssociation_2"> <bpmn2:sourceRef>DataOutput_4</bpmn2:sourceRef> <bpmn2:targetRef>x</bpmn2:targetRef> </bpmn2:dataOutputAssociation> <bpmn2:outputSet id="OutputSet_3" name="OutputSet_3"> <bpmn2:dataOutputRefs>DataOutput_4</bpmn2:dataOutputRefs> </bpmn2:outputSet> <bpmn2:signalEventDefinition id="no"/> <bpmn2:eventDefinitionRef>no</bpmn2:eventDefinitionRef> </bpmn2:intermediateCatchEvent> <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="splitGateWay" targetRef="IntermediateCatchEvent_1"/> <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="splitGateWay" targetRef="IntermediateCatchEvent_2"/> <bpmn2:scriptTask id="ScriptTask_2" name="Script Task"> <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_16</bpmn2:outgoing> <bpmn2:script>System.out.println("Executing No");</bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="IntermediateCatchEvent_1" targetRef="ScriptTask_1"/> <bpmn2:sequenceFlow id="SequenceFlow_12" name="" sourceRef="IntermediateCatchEvent_2" targetRef="ScriptTask_2"/> <bpmn2:scriptTask id="ScriptTask_1" name="Script Task"> <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> <bpmn2:script>System.out.println("Executing Yes");</bpmn2:script> </bpmn2:scriptTask> <bpmn2:exclusiveGateway id="ExclusiveGateway_1" name="join" gatewayDirection="Converging"> <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> <bpmn2:incoming>SequenceFlow_16</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> </bpmn2:exclusiveGateway> <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="ScriptTask_1" targetRef="ExclusiveGateway_1"/> <bpmn2:sequenceFlow id="SequenceFlow_16" name="" sourceRef="ScriptTask_2" targetRef="ExclusiveGateway_1"/> <bpmn2:task id="Task_1" name="endNotifyEmail"> <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> <bpmn2:ioSpecification id="InputOutputSpecification_1"> <bpmn2:inputSet id="InputSet_1"/> <bpmn2:outputSet id="OutputSet_1"/> </bpmn2:ioSpecification> </bpmn2:task> <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="ExclusiveGateway_1" targetRef="Task_1"/> <bpmn2:endEvent id="EndEvent_1" name="End"> <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> <bpmn2:terminateEventDefinition id="_BZwq0DwmEeGrPbDi5iXl5A"/> </bpmn2:endEvent> <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="Task_1" targetRef="EndEvent_1"/> <bpmn2:property id="x"/> </bpmn2:process> <bpmn2:collaboration id="Collaboration_1"> <bpmn2:participant id="Participant_1" name="Internal" processRef="com.sample.test"/> </bpmn2:collaboration> <bpmn2:itemDefinition id="_xItem"/> <bpmndi:BPMNDiagram id="_Z3544DwfEeGrPbDi5iXl5A"> <bpmndi:BPMNPlane id="_Z3544TwfEeGrPbDi5iXl5A" bpmnElement="com.sample.test"> <bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="startEvent"> <dc:Bounds height="51.0" width="36.0" x="70.0" y="135.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_Task_2" bpmnElement="startNotifyEmail"> <dc:Bounds height="51.0" width="111.0" x="160.0" y="127.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_EventBasedGateway_1" bpmnElement="splitGateWay"> <dc:Bounds height="65.0" width="50.0" x="380.0" y="127.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_IntermediateCatchEvent_1" bpmnElement="IntermediateCatchEvent_1"> <dc:Bounds height="51.0" width="36.0" x="470.0" y="100.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_IntermediateCatchEvent_2" bpmnElement="IntermediateCatchEvent_2"> <dc:Bounds height="51.0" width="36.0" x="470.0" y="156.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_ScriptTask_1" bpmnElement="ScriptTask_1"> <dc:Bounds height="46.0" width="111.0" x="560.0" y="95.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_ScriptTask_2" bpmnElement="ScriptTask_2"> <dc:Bounds height="47.0" width="111.0" x="560.0" y="152.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_ExclusiveGateway_1" bpmnElement="ExclusiveGateway_1"> <dc:Bounds height="65.0" width="50.0" x="700.0" y="127.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_Task_1" bpmnElement="Task_1"> <dc:Bounds height="43.0" width="101.0" x="780.0" y="131.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="EndEvent_1"> <dc:Bounds height="51.0" width="36.0" x="910.0" y="130.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="startFlow" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_Task_2"> <di:waypoint xsi:type="dc:Point" x="106.0" y="153.0"/> <di:waypoint xsi:type="dc:Point" x="160.0" y="152.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="processSplitInFlow" sourceElement="BPMNShape_Task_2" targetElement="BPMNShape_EventBasedGateway_1"> <di:waypoint xsi:type="dc:Point" x="271.0" y="152.0"/> <di:waypoint xsi:type="dc:Point" x="380.0" y="152.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_6" sourceElement="BPMNShape_EventBasedGateway_1" targetElement="BPMNShape_IntermediateCatchEvent_1"> <di:waypoint xsi:type="dc:Point" x="431.0" y="152.0"/> <di:waypoint xsi:type="dc:Point" x="470.0" y="118.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_8" sourceElement="BPMNShape_EventBasedGateway_1" targetElement="BPMNShape_IntermediateCatchEvent_2"> <di:waypoint xsi:type="dc:Point" x="431.0" y="152.0"/> <di:waypoint xsi:type="dc:Point" x="470.0" y="174.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_10" sourceElement="BPMNShape_IntermediateCatchEvent_1" targetElement="BPMNShape_ScriptTask_1"> <di:waypoint xsi:type="dc:Point" x="506.0" y="118.0"/> <di:waypoint xsi:type="dc:Point" x="560.0" y="118.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_12" sourceElement="BPMNShape_IntermediateCatchEvent_2" targetElement="BPMNShape_ScriptTask_2"> <di:waypoint xsi:type="dc:Point" x="506.0" y="174.0"/> <di:waypoint xsi:type="dc:Point" x="560.0" y="175.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_14" sourceElement="BPMNShape_ScriptTask_1" targetElement="BPMNShape_ExclusiveGateway_1"> <di:waypoint xsi:type="dc:Point" x="671.0" y="118.0"/> <di:waypoint xsi:type="dc:Point" x="700.0" y="152.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_16" sourceElement="BPMNShape_ScriptTask_2" targetElement="BPMNShape_ExclusiveGateway_1"> <di:waypoint xsi:type="dc:Point" x="671.0" y="175.0"/> <di:waypoint xsi:type="dc:Point" x="700.0" y="152.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_2" sourceElement="BPMNShape_ExclusiveGateway_1" targetElement="BPMNShape_Task_1"> <di:waypoint xsi:type="dc:Point" x="751.0" y="152.0"/> <di:waypoint xsi:type="dc:Point" x="780.0" y="152.0"/> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_4" sourceElement="BPMNShape_Task_1" targetElement="BPMNShape_EndEvent_1"> <di:waypoint xsi:type="dc:Point" x="881.0" y="152.0"/> <di:waypoint xsi:type="dc:Point" x="910.0" y="148.0"/> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions>
And got below logs:
(null: 2, 350): cvc-elt.1: Cannot find the declaration of element 'bpmn2:definitions'. (null: 124, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 125, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 128, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 129, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 132, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 133, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 136, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 137, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 140, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 141, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 144, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 145, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 148, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 149, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 152, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 153, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 156, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 157, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 160, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. (null: 161, 63): cvc-elt.4.2: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. [-1,-1]: Process 'Test' [com.sample.test]: Event node 'event' [4] should specify an event type [-1,-1]: Process 'Test' [com.sample.test]: Event node 'event2' [5] should specify an event type Exception in thread "main" java.lang.IllegalArgumentException: Could not parse knowledge. at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:67) at com.test.workflow.BPMN2Test.main(BPMN2Test.java:17)
For the message: Cannot resolve 'dc:Point' to a type definition for element 'di:waypoint'. It's mentioned in the https://issues.jboss.org/browse/JBPM-3143.
For
[-1,-1]: Process 'Test' [com.sample.test]: Event node 'event' [4] should specify an event type
[-1,-1]: Process 'Test' [com.sample.test]: Event node 'event2' [5] should specify an event type
Exception in thread "main" java.lang.IllegalArgumentException: Could not parse knowledge.
at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:67)
at com.test.workflow.BPMN2Test.main(BPMN2Test.java:17)
where should i specify the event type?
Thanks very much.
forgive me for my bad english.