2016-03-28 1 views
1

Ich arbeite an jbpm Beispiel wie das folgende Tutorial https://docs.jboss.org/jbpm/v5.3/userguide/ch.quickstarts.html#d0e1137, aber ich bekomme ein Problem in der Benutzervariable zu Skript-Task-Prozess, So bekomme ich die folgende Nachricht
com/innvo/Process_com $ u46 $ Innvo $ U46 $ U46 $ Drools_Work_Flow_Example421421234.java (16: 701): Benutzer kann nicht auf eine VariableVariable auf Skript-Task-Prozess in jbpmm setzen

public static void main(String arg[]){ 

     User user=new User(); 
     user.setName("123123"); 
     user.setMail("456456"); 
     KieServices ks = KieServices.Factory.get(); 
     KieContainer kContainer = ks.getKieClasspathContainer(); 
     KieSession kSession = kContainer.newKieSession("ksession-process"); 
     Map<String, Object> params=new HashMap<String,Object>(); 
     params.put("user", user); 
     kSession.startProcess("com.innvo", params); 

    } 

Skript Aufgabencode aufgelöst werden Benutzer

System.out.println(user.getName()); 

bpmn Code

012.351.641 drucken
<?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:g="http://www.jboss.org/drools/flow/gpd" 
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:process id="com.innvo.drools" tns:version="1" 
tns:packageName="com.innvo.drools" tns:adHoc="false" name="Drools Work 
Flow Example" isExecutable="true" processType="Private"> 
<bpmn2:extensionElements> 
    <tns:import name="org.kie.api.runtime.ObjectFilter"/> 
    <tns:import name="java.util.ArrayList"/> 
    <tns:import name="java.util.List"/> 
    <tns:import name="com.innvo.domain.Score"/> 
    <tns:import name="org.kie.api.runtime.rule.FactHandle"/> 
    <tns:import name="com.innvo.drools.ScoreService"/> 
</bpmn2:extensionElements> 
<bpmn2:startEvent id="_1" name=""> 
    <bpmn2:outgoing>_1-_jbpm-unique-6</bpmn2:outgoing> 
</bpmn2:startEvent> 
<bpmn2:sequenceFlow id="_1-_jbpm-unique-6" tns:priority="1" name="" 
sourceRef="_1" targetRef="ScriptTask_1"/> 
<bpmn2:scriptTask id="ScriptTask_1" name="Script Task 1" 
scriptFormat="http://www.java.com/java"> 
    <bpmn2:incoming>_1-_jbpm-unique-6</bpmn2:incoming> 
    <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> 
    <bpmn2:script>kcontext.setVariable(&quot;scoreRouteRulefile&quot;, 
    &quot;scoreRouteRulefile&quot;); 
    System.out.println(scoreRouteRulefile);</bpmn2:script> 
</bpmn2:scriptTask> 
<bpmn2:sequenceFlow id="SequenceFlow_1" tns:priority="1" name="" 
sourceRef="ScriptTask_1" targetRef="_jbpm-unique-6"/> 
<bpmn2:endEvent id="_3" name=""> 
    <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> 
    <bpmn2:terminateEventDefinition id="TerminateEventDefinition_1"/> 
</bpmn2:endEvent> 
<bpmn2:businessRuleTask id="_jbpm-unique-6" tns:ruleFlowGroup="" 
g:ruleFlowGroup="Group1" name="rule"> 
    <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> 
    <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> 
    <bpmn2:ioSpecification id="InputOutputSpecification_1"> 
    <bpmn2:inputSet id="InputSet_1"/> 
    <bpmn2:outputSet id="OutputSet_1"/> 
    </bpmn2:ioSpecification> 
</bpmn2:businessRuleTask> 
<bpmn2:sequenceFlow id="SequenceFlow_2" tns:priority="1" name="" 
    sourceRef="_jbpm-unique-6" targetRef="_3"/> 
</bpmn2:process> 
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> 
<bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="com.innvo.drools"> 
    <bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="_1"> 
    <dc:Bounds height="48.0" width="48.0" x="75.0" y="133.0"/> 
    </bpmndi:BPMNShape> 
    <bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="_3"> 
    <dc:Bounds height="48.0" width="48.0" x="590.0" y="133.0"/> 
    </bpmndi:BPMNShape> 
    <bpmndi:BPMNShape id="BPMNShape_ScriptTask_1" 
     bpmnElement="ScriptTask_1"> 
    <dc:Bounds height="50.0" width="110.0" x="220.0" y="132.0"/> 
    </bpmndi:BPMNShape> 
    <bpmndi:BPMNShape id="BPMNShape_BusinessRuleTask_1" bpmnElement="_jbpm- 
     unique-6"> 
    <dc:Bounds height="48.0" width="80.0" x="420.0" y="133.0"/> 
    </bpmndi:BPMNShape> 
    <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="_1-_jbpm- 
    unique-6" sourceElement="BPMNShape_StartEvent_1" 
    targetElement="BPMNShape_ScriptTask_1"> 
    <di:waypoint xsi:type="dc:Point" x="123.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="216.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="216.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="220.0" y="157.0"/> 
    </bpmndi:BPMNEdge> 
    <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" 
    bpmnElement="SequenceFlow_1" sourceElement="BPMNShape_ScriptTask_1" 
    targetElement="BPMNShape_BusinessRuleTask_1"> 
    <di:waypoint xsi:type="dc:Point" x="330.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="406.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="406.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="420.0" y="157.0"/> 
    </bpmndi:BPMNEdge> 
    <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" 
bpmnElement="SequenceFlow_2" 
    sourceElement="BPMNShape_BusinessRuleTask_1" 
     targetElement="BPMNShape_EndEvent_1"> 
    <di:waypoint xsi:type="dc:Point" x="500.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="570.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="570.0" y="157.0"/> 
    <di:waypoint xsi:type="dc:Point" x="590.0" y="157.0"/> 
    </bpmndi:BPMNEdge> 
</bpmndi:BPMNPlane> 
</bpmndi:BPMNDiagram> 
</bpmn2:definitions> 

Antwort

1

(I User und user in meiner Antwort verwenden werden, auch wenn Ihre Prozessdefinition scoreRouteRulefile verwendet)

Soweit ich sehen kann, haben Sie nicht eine Variable in Ihrem Prozess definiert mit der Name user und Typ User. Das Senden von Parametern beim Start einer Prozessinstanz legt sie nicht automatisch als Prozessvariablen fest. Was Sie tun müssen, ist eine Variable im Prozess mit dem gleichen Namen, den Sie für den Schlüssel des Arguments user und den gleichen Typ des Objekts, das Sie übergeben (User) übergeben. Wenn Sie im jbpm-Designer arbeiten, klicken Sie auf den Hintergrund des Prozesses und gehen Sie zur Attributpalette. Dort finden Sie ein Attribut, das die Variablen des Prozesses definiert.

Ich hoffe, es hilft,

Verwandte Themen