[jboss-dev-forums] [jBPM Development] - Re: Unable to start-up human task

phumla Andrease do-not-reply at jboss.com
Tue Jul 26 10:37:59 EDT 2011


phumla Andrease [http://community.jboss.org/people/paa] created the discussion

"Re: Unable to start-up human task"

To view the discussion, visit: http://community.jboss.org/message/617652#617652

--------------------------------------------------------------
No Luck!!!

I changed it to the following::


| package com.jbpm.process;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.drools.KnowledgeBase;
import org.drools.SystemEventListenerFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.process.workitem.wsht.WSHumanTaskHandler;
import org.jbpm.task.query.TaskSummary;
import org.jbpm.task.service.TaskClient;
import org.jbpm.task.service.mina.MinaTaskClientConnector;
import org.jbpm.task.service.mina.MinaTaskClientHandler;
import org.jbpm.task.service.responsehandlers.BlockingTaskOperationResponseHandler;
import org.jbpm.task.service.responsehandlers.BlockingTaskSummaryResponseHandler;

/**
 * This is a sample file to launch a process.
 */
public class ProcessTest {

    public static final void main(String[] args) {
        try {
            // load up the knowledge base
            KnowledgeBase kbase = readKnowledgeBase();
            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
            KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);
            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());
            // start a new process instance
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("employee", "Krisv");
            params.put("comment", "Load login screen");
        ksession.startProcess("com.jbpm.process.captureProcess", params);

        //Krisv Start process
        SystemEventListenerFactory.setSystemEventListener(new SystemEventListener());
        TaskClient taskClient = new TaskClient(new MinaTaskClientConnector("MinaConnector",
        new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
        taskClient.connect("127.0.0.1", 9123);
        Thread.sleep(1000);

        BlockingTaskSummaryResponseHandler taskSummaryHandler = new BlockingTaskSummaryResponseHandler();
        taskClient.getTasksAssignedAsPotentialOwner("Krisv", "en-UK", taskSummaryHandler);
        TaskSummary task1 = taskSummaryHandler.getResults().get(0);
        System.out.println("Krisv executing task " + task1.getName() + "(" + task1.getId() + ": " + task1.getDescription() + ")");
        BlockingTaskOperationResponseHandler taskOperationHandler = new BlockingTaskOperationResponseHandler();

        taskClient.start(task1.getId(), "krisv", taskOperationHandler);
        taskOperationHandler.waitTillDone(1000);
        taskOperationHandler = new BlockingTaskOperationResponseHandler();
        taskClient.complete(task1.getId(), "krisv", null, taskOperationHandler);
        taskOperationHandler.waitTillDone(1000);
        Thread.sleep(1000);

        //john Load screen 
        taskSummaryHandler = new BlockingTaskSummaryResponseHandler();
        List<String> groups = new ArrayList<String>();
        groups.add("FP");
        taskClient.getTasksAssignedAsPotentialOwner("mary", groups, "en-UK", taskSummaryHandler);
        TaskSummary task2 = taskSummaryHandler.getResults().get(0);
        System.out.println("mary executing task " + task2.getName() + "(" + task2.getId() + ": " + task2.getDescription() + ")");
        taskOperationHandler = new BlockingTaskOperationResponseHandler();
        taskClient.claim(task2.getId(), "mary", groups, taskOperationHandler);
        taskOperationHandler.waitTillDone(1000);
        taskOperationHandler = new BlockingTaskOperationResponseHandler();
        taskClient.start(task2.getId(), "mary", taskOperationHandler);
        taskOperationHandler.waitTillDone(1000);
        taskOperationHandler = new BlockingTaskOperationResponseHandler();
        taskClient.complete(task2.getId(), "mary", null, taskOperationHandler);
        taskOperationHandler.waitTillDone(1000);
        Thread.sleep(1000);




            logger.close();
        } catch (Throwable t) 
        {
            t.printStackTrace();
        }
    }

    private static KnowledgeBase readKnowledgeBase() throws Exception 
    {
        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add(ResourceFactory.newClassPathResource("Capture.bpmn"), ResourceType.BPMN2);
        return kbuilder.newKnowledgeBase();
    }

    private static class SystemEventListener implements org.drools.SystemEventListener 
    {
        public void debug(String arg0) {
        }
        public void debug(String arg0, Object arg1) {
        }
        public void exception(Throwable arg0) {
        }
        public void exception(String arg0, Throwable arg1) {
        }
        public void info(String arg0) {
        }
        public void info(String arg0, Object arg1) {
        }
        public void warning(String arg0) {
        }
        public void warning(String arg0, Object arg1) {
        }
    }

} |


And here with my bpmn xml...

|| *Header 1* ||
| <?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">

  <itemDefinition id="_employeeItem" />
  <itemDefinition id="_detailsItem" />
  <itemDefinition id="_loadScreenItem" />
  <itemDefinition id="_LogOnItem" />
  <itemDefinition id="_commentItem" />
  <itemDefinition id="_contentParamItem" structureRef="java.util.HashMap" />
  <itemDefinition id="_dateItem" />
  <itemDefinition id="_contentItem" structureRef="java.util.HashMap" />

  <process processType="Private" isExecutable="true" id="com.jbpm.process.captureProcess" name="Capture" tns:packageName="defaultPackage" >

    <!-- process variables -->
    <property id="employee" itemSubjectRef="_employeeItem"/>
    <property id="details" itemSubjectRef="_detailsItem"/>
    <property id="loadScreen" itemSubjectRef="_loadScreenItem"/>
    <property id="LogOn" itemSubjectRef="_LogOnItem"/>
    <property id="comment" itemSubjectRef="_commentItem"/>
    <property id="contentParam" itemSubjectRef="_contentParamItem"/>
    <property id="date" itemSubjectRef="_dateItem"/>
    <property id="content" itemSubjectRef="_contentItem"/>

    <!-- nodes -->
    <startEvent id="_1" name="Start" />
    <userTask id="_2" name="Click  link" >
      <extensionElements>
        <tns:onEntry-script scriptFormat="http://www.java.com/java">
          <script>System.out.println("Starting Process");
contentParam=new java.util.HashMap();
contentParam.put("employee",employee);
contentParam.put("comment",comment);
kcontext.setVariable("contentParam",contentParam);</script>
        </tns:onEntry-script>
      </extensionElements>
      <ioSpecification>
        <dataInput id="_2_contentInput" name="content" />
        <dataInput id="_2_CommentInput" name="Comment" />
        <dataInput id="_2_SkippableInput" name="Skippable" />
        <dataInput id="_2_TaskNameInput" name="TaskName" />
        <dataInput id="_2_ContentInput" name="Content" />
        <dataInput id="_2_PriorityInput" name="Priority" />
        <dataOutput id="_2_commentOutput" name="comment" />
        <inputSet>
          <dataInputRefs>_2_contentInput</dataInputRefs>
          <dataInputRefs>_2_CommentInput</dataInputRefs>
          <dataInputRefs>_2_SkippableInput</dataInputRefs>
          <dataInputRefs>_2_TaskNameInput</dataInputRefs>
          <dataInputRefs>_2_ContentInput</dataInputRefs>
          <dataInputRefs>_2_PriorityInput</dataInputRefs>
        </inputSet>
        <outputSet>
          <dataOutputRefs>_2_commentOutput</dataOutputRefs>
        </outputSet>
      </ioSpecification>
      <dataInputAssociation>
        <sourceRef>contentParam</sourceRef>
        <targetRef>_2_contentInput</targetRef>
      </dataInputAssociation>
      <dataInputAssociation>
        <targetRef>_2_CommentInput</targetRef>
        <assignment>
          <from xsi:type="tFormalExpression">Click to load screen</from>
          <to xsi:type="tFormalExpression">_2_CommentInput</to>
        </assignment>
      </dataInputAssociation>
      <dataInputAssociation>
        <targetRef>_2_SkippableInput</targetRef>
        <assignment>
          <from xsi:type="tFormalExpression">false</from>
          <to xsi:type="tFormalExpression">_2_SkippableInput</to>
        </assignment>
      </dataInputAssociation>
      <dataInputAssociation>
        <targetRef>_2_TaskNameInput</targetRef>
        <assignment>
          <from xsi:type="tFormalExpression">Load Screen Link</from>
          <to xsi:type="tFormalExpression">_2_TaskNameInput</to>
        </assignment>
      </dataInputAssociation>
      <dataInputAssociation>
        <targetRef>_2_ContentInput</targetRef>
        <assignment>
          <from xsi:type="tFormalExpression"></from>
          <to xsi:type="tFormalExpression">_2_ContentInput</to>
        </assignment>
      </dataInputAssociation>
      <dataInputAssociation>
        <targetRef>_2_PriorityInput</targetRef>
        <assignment>
          <from xsi:type="tFormalExpression"></from>
          <to xsi:type="tFormalExpression">_2_PriorityInput</to>
        </assignment>
      </dataInputAssociation>
      <dataOutputAssociation>
        <sourceRef>_2_commentOutput</sourceRef>
        <targetRef>comment</targetRef>
      </dataOutputAssociation>
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>#{employee}</formalExpression>
        </resourceAssignmentExpression>
      </potentialOwner>
    </userTask>
    <userTask id="_3" name="First Screen" >
      <extensionElements>
        <tns:onEntry-script scriptFormat="http://www.java.com/java">
          <script>System.out.println("Starting Process");</script>
        </tns:onEntry-script>
      </extensionElements>
      <ioSpecification>
        <dataInput id="_3_commentInput" name="comment" />
        <dataInput id="_3_TaskNameInput" name="TaskName" />
        <dataInput id="_3_GroupIdInput" name="GroupId" />
        <inputSet>
          <dataInputRefs>_3_commentInput</dataInputRefs>
          <dataInputRefs>_3_TaskNameInput</dataInputRefs>
          <dataInputRefs>_3_GroupIdInput</dataInputRefs>
        </inputSet>
        <outputSet>
        </outputSet>
      </ioSpecification>
      <dataInputAssociation>
        <sourceRef>comment</sourceRef>
        <targetRef>_3_commentInput</targetRef>
      </dataInputAssociation>
      <dataInputAssociation>
        <targetRef>_3_TaskNameInput</targetRef>
        <assignment>
          <from xsi:type="tFormalExpression">FirstScreen</from>
          <to xsi:type="tFormalExpression">_3_TaskNameInput</to>
        </assignment>
      </dataInputAssociation>
      <dataInputAssociation>
        <targetRef>_3_GroupIdInput</targetRef>
        <assignment>
          <from xsi:type="tFormalExpression">FP</from>
          <to xsi:type="tFormalExpression">_3_GroupIdInput</to>
        </assignment>
      </dataInputAssociation>
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>mary</formalExpression>
        </resourceAssignmentExpression>
      </potentialOwner>
    </userTask>
    <endEvent id="_6" name="End" >
        <terminateEventDefinition/>
    </endEvent>
    <scriptTask id="_7" name="Script" >
      <script>System.out.println("Go to  Next");</script>
    </scriptTask>

    <!-- connections -->
    <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
    <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" />
    <sequenceFlow id="_7-_6" sourceRef="_7" targetRef="_6" />
    <sequenceFlow id="_3-_7" sourceRef="_3" targetRef="_7" />

  </process>

  <bpmndi:BPMNDiagram>
    <bpmndi:BPMNPlane bpmnElement="com.jbpm.process.captureProcess" >
      <bpmndi:BPMNShape bpmnElement="_1" >
        <dc:Bounds x="14" y="104" width="48" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_2" >
        <dc:Bounds x="146" y="104" width="100" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_3" >
        <dc:Bounds x="295" y="105" width="100" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_6" >
        <dc:Bounds x="608" y="106" width="48" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_7" >
        <dc:Bounds x="460" y="108" width="80" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="_1-_2" >
        <di:waypoint x="38" y="128" />
        <di:waypoint x="196" y="128" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_2-_3" >
        <di:waypoint x="196" y="128" />
        <di:waypoint x="345" y="129" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_7-_6" >
        <di:waypoint x="500" y="132" />
        <di:waypoint x="632" y="130" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_3-_7" >
        <di:waypoint x="345" y="129" />
        <di:waypoint x="500" y="132" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>

</definitions> |
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/617652#617652]

Start a new discussion in jBPM Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2035]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20110726/4f20b37d/attachment.html 


More information about the jboss-dev-forums mailing list