2 Replies Latest reply: Jun 19, 2012 4:58 AM by Krishna Pitla RSS

Run the sample JBPM process with java code, but i also want the process instance to be displayed on jBPM-console.

Krishna Pitla Newbie

Hi All,

 

I am new to JBPM5.2. I am able to run the sample JBPM process with java code, but i also want the process instance to be displayed on jBPM-console.

I have deployed the process on guvnor and the process is available in the Process Overview . But the process instance doesnt show as started on the jBPM-console. Please help !!!!

  • 1. Re: Run the sample JBPM process with java code, but i also want the process instance to be displayed on jBPM-console.
    Maciej Swiderski Master

    Do you have any state nodes in your process? If not, the process instance will not show up in the console as it will be finished before console will query for active processes.

     

    HTH

  • 2. Re: Run the sample JBPM process with java code, but i also want the process instance to be displayed on jBPM-console.
    Krishna Pitla Newbie

    hi maciej,

     

    Sorry for the late reply. Thanks a lot for your response.

    I have used the state nodes like human task in the process.

     

    The java code that i use to run the process is as below:

    package com.sample;

     

    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.logger.KnowledgeRuntimeLoggerFactory;

    import org.drools.runtime.StatefulKnowledgeSession;

    import org.jbpm.process.workitem.wsht.CommandBasedWSHumanTaskHandler;

    import org.jbpm.test.JBPMHelper;

     

    /**

    * This is a sample file to launch a process.

    */

    public class ProcessMain {

     

        public static final void main(String[] args) throws Exception {

           

            // load up the knowledge base

            KnowledgeBase kbase = readKnowledgeBase();

            //StatefulKnowledgeSession ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);

            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

           

            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));

           

            KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);

            // start a new process instance

            ksession.startProcess("KrpiSample");

            System.out.println("Process started ...");

        }

     

        private static KnowledgeBase readKnowledgeBase() throws Exception {

            KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

            kbuilder.add(ResourceFactory.newClassPathResource("Krpi_sample.bpmn"), ResourceType.BPMN2);

            return kbuilder.newKnowledgeBase();

        }

            

    }