JBoss Community

Domain-specific process doesn't start

created by Laura delli Paoli in jBPM - View the full discussion

Hello everybody,

I'm  using JBoss AS 7.1.1 and jBPM 5.4.

I was trying to define my custom process "Run Action".

1) I created my "MyProcessesDefinition.conf" file:

import org.drools.process.core.datatype.impl.type.ObjectDataType;

import org.drools.process.core.datatype.impl.type.StringDataType;

import org.drools.process.core.datatype.impl.type.IntegerDataType;

[

  // my workItem

  [

    "name" : "RunAction",

    "parameters" : [

      "Command" : new StringDataType(),

      "Parameters" : new ObjectDataType(),

    ],

    "results" : [

      "ExitValue" : new IntegerDataType(),

    ],

    "displayName" : "RunAction",

    "icon" : "icons/operation.ico"

  ]

 

 

]

2) I created my "drools.rulebase.conf"

drools.workDefinitions = MyProcessesDefinition.conf WorkDefinitions.conf

3) I created the the RunAction handler

 

public class RunActionHandler implements WorkItemHandler {

 

 

          @Override

          public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {

                    // extract parameters

              String command = (String) workItem.getParameter("Command");

             

              HashMap parameters = (HashMap) workItem.getParameter("Parameters");

 

 

              // run command

                      

              String command_with_params =command;

              Runtime runtime = Runtime.getRuntime();

              Process process = null;

         

              System.out.println("okkk");

             

             

              Map<String, Object> result = new HashMap<String, Object>();

             

               result.put("ExitValue", new Integer (0));

             

              // notify manager that work item has been completed

             

             manager.completeWorkItem(workItem.getId(), result);

 

          }

 

 

          @Override

          public void executeWorkItem(WorkItem arg0, WorkItemManager arg1) {

                    // Se invio un Ctrl+C interrompo il task????

          }

 

}

 

4)I created the process depicted in the attachement

5) I wrote the following main:

public class ProcessMain {

 

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

                    // load up the knowledge base

                    KnowledgeBase kbase = readKnowledgeBase();

                    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

 

                    ksession.getWorkItemManager().registerWorkItemHandler("RunAction", new RunActionHandler());

 

                    Map<String, Object> params = new HashMap<String, Object>();

                    Object workflowName= new String ("C:\test.bat"), Properties = new String("");

                    params.put("Command", workflowName);

                    params.put("Parameters", Properties);

 

                    // start a new process instance

                    ksession.startProcess("wkfRepository.singleTaskWkf", params);

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

          }

 

 

          private static KnowledgeBase readKnowledgeBase() throws Exception {

                    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

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

                    return kbuilder.newKnowledgeBase();

          } 

}

 

When I start the JBoss server, and run the the java application the process ends, but the custom process does not start (the "okkk" message is NOT printed).

 

Can anyone help me?

Reply to this message by going to Community

Start a new discussion in jBPM at Community