Starting a process instance using a KieSession

Latest response

Hello,

We have a simple process that contains a Human Task.

If the process is started through JBPM Console, then a new process instance is created and a new process instance is show correctly in the Process Instances list of JBPM.

Now, we have the process being started through code using a KieSession. We are using the following code:

RuntimeManager runtimeManager;

ReleaseId releaseId = new ReleaseIdImpl(artifactCoordinates.getGroupId(), artifactCoordinates.getArtifactId(), artifactCoordinates.getVersion());

RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault(releaseId).entityManagerFactory(Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME)).userGroupCallback(new JBossUserGroupCallbackImpl("classpath:/usergroup.properties")).get();

((SimpleRegisterableItemsFactory) environment.getRegisterableItemsFactory()).addWorkItemHandler(LOGGER_WORKITEM_HANDLER, LoggerHandler.class);
((SimpleRegisterableItemsFactory) environment.getRegisterableItemsFactory()).addWorkItemHandler(WEB_SERVICE_WORKITEM_HANDLER, WebServiceWorkItemHandler.class);

runtimeManager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);

RuntimeEngine engine = runtimeManager.getRuntimeEngine(EmptyContext.get());

KieSession kSession = engine.getKieSession();

kieSession.startProcess(jbpmProcessDetails.getProcessName(), jbpmProcessDetails.getProcessParams());

The instance of jbpmProcessDetails contains the correct information to start the process.

We have a kjar in maven repository that contains the process definition, identified by the artifactCoordinates, and this java code is running on a different machine than JBPM Console, however the Persistence Unit is configured to use the same database as the JBPM Console.

We also have a userinfo.properties in the classpath with the following contents:

admin=admin@example.com:en-UK:admin

The file usergroups.properties have the following contents:

admin=admin,analyst

When we start a process with the previous code, a new task is created for the user admin, and it shows up in the task list of jbpmConsole.

However in the process Instances list, the instance shows without an initiator. (See attachments)

Also, when we try to open the Process Model from an instance initiated programmatically we get an error with the following message:

"Process definition not found, most likely is not deployed"
See atachments.

Can you please give us advice on how to correctly start a process instance programmatically? What is missing in our code?

Attachments

Responses

Joao, I suspect you might need to open a support case for assistance with this. The JBoss.org community is also a good source for developer advice.