I am currently trying to bootstrap the engine standalone in memory with an in-memory database as well. I am able to deploy the process and it seems to be valid as per Bpmn.validateModel().
This is what I am doing for starting my process:
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP).setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000") .buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
String deploymentId = repositoryService.createDeployment().addModelInstance("Instance1", modelInstance).deploy().getId();
List<String> deploymentResources = repositoryService.getDeploymentResourceNames(deploymentId);
assertEquals(1, deploymentResources.size());
InputStream deploymentInputStream = repositoryService.getResourceAsStream(deploymentId, deploymentResources.get(0));
String contentFromDeployment = readInputStreamToString(deploymentInputStream);
System.out.println(contentFromDeployment);
repositoryService.activateProcessDefinitionByKey("process-with-one-task");
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process-with-one-task");
My process model which I get back from this call System.out.println(contentFromDeployment); looks the following:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions targetNamespace="http://camunda.org/examples" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">
<process id="process-with-one-task">
<startEvent id="start">
<outgoing>start-task1</outgoing>
</startEvent>
<userTask id="task1" name="User Task">
<incoming>start-task1</incoming>
<outgoing>task1-end</outgoing>
</userTask>
<endEvent id="end">
<incoming>task1-end</incoming>
</endEvent>
<sequenceFlow id="start-task1" sourceRef="start" targetRef="task1"/>
<sequenceFlow id="task1-end" sourceRef="task1" targetRef="end"/>
</process>
</definitions>
I call repositoryService.activateProcessDefinitionByKey("process-with-one-task"); and it works as far as I don't get an error for this :) ... but when I now call runtimeService.startProcessInstanceByKey("process-with-one-task"); I get the following exception:
SCHWERWIEGEND: Error while closing command context
org.camunda.bpm.engine.exception.NullValueException: no processes deployed with key 'process-with-one-task': processDefinition is null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:283)
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:44)
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:39)
at org.camunda.bpm.engine.impl.persistence.deploy.DeploymentCache.findDeployedLatestProcessDefinitionByKey(DeploymentCache.java:90)
at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:63)
at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:35)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:97)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)
at org.camunda.bpm.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:66)
at com.bearingpoint.bpmn.test.TestCreation.createModel(TestCreation.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
What am I missing to successfully deploy and start this specific process? I tried several other variants including starting the process via the startProcessInstanceById(...)
and deploying the model differently as shown in some of your unittests on github but it either resulted in a NullPointerException or the exception shown above.
Thank you for your help already and kind regards,
Francesca
String deploymentId = repositoryService.createDeployment().addModelInstance("Instance1.bpmn", modelInstance).deploy().getId();ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertEquals("process-with-one-task", processDefinition.getKey());<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://activiti.org/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_pBCBME-4EeWz-IOMgTJR7g" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://activiti.org/bpmn">
<bpmn2:collaboration id="_Collaboration_3">
<bpmn2:participant id="new_mutation" name="New Mutation Request" processRef="hrmutations_app"/>
</bpmn2:collaboration>
<bpmn2:process id="hrmutations_app" name="HRMutation" isExecutable="true">
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
<bpmn2:lane id="dg_sd_hr_correspondent" name="DG/SD-HR Correspondent">
<bpmn2:flowNodeRef>ParallelGateway_1</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>StartEvent_newMutation</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>SubProcess_MutationBuilding</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>EndEvent_CancelledMutation</bpmn2:flowNodeRef>
public class CamundaAPITest{
private static ProcessEngine processEngine;
static{
processEngine = StandaloneInMemProcessEngineConfiguration.
createStandaloneInMemProcessEngineConfiguration().
buildProcessEngine();
}
@Rule
public ProcessEngineRule processEngineRule = new ProcessEngineRule(processEngine);
@Test
@Deployment(resources = "hrmutations_new_test.bpmn")
public void testInstantiateProcessInstance(){
RuntimeService runtimeService = processEngineRule.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(HRMutationProcessActivity.hrMutationsProcessName);
/*Assert.assertNotNull(processInstance);*/
}
HRMutationProcessActivity.hrMutationsProcessName is equal to hrmutations_app so the process ID according to the .bpmn file.
org.camunda.bpm.engine.exception.NullValueException: no deployed process definition found with id 'hrmutations_app': processDefinition is nullruntimeService.startProcessInstance(HRMutationProcessActivity.hrMutationsProcessName, "someBusinessKey");
taskService.createTaskQuery().processInstanceBusinessKey("someBusinessKey").list();