Tuesday, 27 August 2013

Could not parse knowledge - JBPM

Could not parse knowledge - JBPM

This is my code, I am trying to create an application which compares the
loan amount and prints whether its a low amount, high amount or medium
amount:
public static void main(String[] args) {
System.out.println("application starting.....");
KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add(ResourceFactory.newClassPathResource("bpmn/sampleProcess.bpmn"),ResourceType.BPMN2
);
System.out.println("KnowledgeBuilder is :::::: "+kBuilder);
KieBase kBase = kBuilder.newKnowledgeBase();
System.out.println("KieBase is ::::::: "+kBase);
KieSession kSession = kBase.newKieSession();
System.out.println("KSession is :::::::: "+kSession);
// PROCESS PARAMETERS
Map<String,Object> params = new HashMap<>();
//Creating a Person who applies to loan.
Person p = new Person();
p.setName("Ayushya K Devmurari");
p.setUniqueId("A007");
p.setIncome(new BigDecimal(5_00_000.00));
p.setIncome(new BigDecimal(2_40_000.00));
// setting parameter in Map
params.put("Applicant1", p);
//Starting the process.
kSession.startProcess("com.discusit.loanapplication", params);
System.out.println("application now closing.....");
kSession.dispose();
}
And its showing following error:
Exception in thread "main" java.lang.IllegalArgumentException: Could not
parse knowledge.
at
org.drools.compiler.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:79)
at com.discusit.loanapplication.main.MainClass.main(MainClass.java:26)
I am new to Jbpm. And successfully created two more jbpm hello world.
This is my bpmn file:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="Definition"
targetNamespace="http://www.jboss.org/drools"
typeLanguage="http://www.java.com/javaTypes"
expressionLanguage="http://www.mvel.org/2.0"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL
BPMN20.xsd"
xmlns:g="http://www.jboss.org/drools/flow/gpd"
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">
<process processType="Private" isExecutable="true"
id="com.discusit.loanapplication" name="Sample Process"
tns:packageName="defaultPackage" >
<!-- nodes -->
<startEvent id="_1" isInterrupting="true"/>
<exclusiveGateway id="_3" name="Gateway" gatewayDirection="Diverging" />
<scriptTask id="_4" name="Low Amount" >
<script>System.out.println("Amount is Low :::::::");
</script>
</scriptTask>
<scriptTask id="_5" name="Medium Amount" >
<script>System.out.println("Amount is medium :::::");
</script>
</scriptTask>
<scriptTask id="_6" name="High Amount" >
<script>System.out.println("Amount is HIGH :::::::::");</script>
</scriptTask>
<!-- connections -->
<sequenceFlow id="_1-_3" sourceRef="_1" targetRef="_3" />
<sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" name="low
Amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return
loanAmount&lt;50000;</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_3-_5" sourceRef="_3" targetRef="_5" name="medium
amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return (loanAmount
&gt;=50000 &amp;&amp; loanAmount &lt; 100000);
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_3-_6" sourceRef="_3" targetRef="_6" name="high
amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return loanAmount
&gt;=100000;</conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="com.discusit.loanapplication" >
<bpmndi:BPMNShape bpmnElement="_1" >
<dc:Bounds x="261" y="15" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" >
<dc:Bounds x="260" y="225" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" >
<dc:Bounds x="-11" y="405" width="132" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" >
<dc:Bounds x="215" y="406" width="142" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" >
<dc:Bounds x="512" y="407" width="132" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_1-_3" >
<di:waypoint x="285" y="39" />
<di:waypoint x="284" y="249" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_4" >
<di:waypoint x="284" y="249" />
<di:waypoint x="55" y="429" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_5" >
<di:waypoint x="284" y="249" />
<di:waypoint x="286" y="430" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_6" >
<di:waypoint x="284" y="249" />
<di:waypoint x="578" y="431" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
Any help would be appreciated.

No comments:

Post a Comment