1

I would like to execute bpmn file which is in another project. Could anyone tell me how to do this?

I have something like this in my rule, but it's doesn't work:

function performScenario()
{
    KieHelper kHelper = new KieHelper();
    KieBase kBase = kHelper.addResource(ResourceFactory.newFileResource("D:\\jbpm-installer\\workspace\\JbpmTest\\src\\main\\resources\\sample.bpmn")).build();
    KieSession kieSession = kBase.newKieSession();
    kieSession.startProcess("com.sample.bpmn.hello");
}

I have error: Unknown process ID

2 Answers2

1

What do you mean by the process is in another project? You will need to load the project into the same ksession in order to be able to start it from there. Instead of doing this:

kHelper
    .addResource(
        ResourceFactory.newFileResource("D:\\jbpm-installer\\workspace\\JbpmTest\\src\\main\\resources\\sample.bpmn")
    )
    .build();

Just do the same when you build your rules session and then you will be able to do something like

kcontext.startProcess(<ID HERE>);

HTH

danidemi
  • 4,404
  • 4
  • 34
  • 40
salaboy
  • 4,123
  • 1
  • 14
  • 15
0

I think you have an error in kieSession.startProcess("com.sample.bpmn.hello"); The kieSession didn't know the id: "com.sample.bpmn.hello", so it throw an error: Unknown Process ID.

Open your bpmn file in text or xml editor and look for this line of code:

    ...
    <process processType="Private" isExecutable="true" id="Sample" name="Sample Process">
    ...

The id="Sample" is the Process ID. So your code should be like this: kieSession.startProcess("Sample");

vian
  • 13
  • 4