Dmn with bpmn doesn't work (java.lang.NullPointerException at Dmn Activity Behavior)

Hello, I just started working with Flowable, please I have this blocking error that I could not understand the causes.
here is the description:
First, I created a simple process definition with a user task and a decision task, when I launch the bpmn everything goes well but when it arrives at the decision task I have this error.

here is all the code (for test)

  • DMN definition :
    
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20180521/MODEL/" id="definition_b9024221-4440-11ea-ae0c-aeb57d2ff3bd"
 name="decision1" namespace="http://www.flowable.org/dmn">
  <decision id="decisionKey" name="decision1">
    <decisionTable id="decisionTable_b9024221-4440-11ea-ae0c-aeb57d2ff3bd" hitPolicy="FIRST">
      <input label="val1">
        <inputExpression id="inputExpression_1" typeRef="string">
          <text>val1</text>
        </inputExpression>
      </input>
      <output id="outputExpression_2" label="res1" name="res1" typeRef="string"></output>
      <rule>
        <inputEntry id="inputEntry_1_1">
          <text><![CDATA[== "oum"]]></text>
        </inputEntry>
        <outputEntry id="outputEntry_2_1">
          <text><![CDATA["resuOk"]]></text>
        </outputEntry>
      </rule>
    </decisionTable>
  </decision>
</definitions>
  • Bpmn definition :
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" 
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" 
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef">
  <process id="testProcess" name="testProcess" isExecutable="true">
    <startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
    
   <sequenceFlow id="sid-F38562FD-19FB-4053-8783-BF8CE5B07D22" sourceRef="startEvent1" targetRef="testProcessUserTask"></sequenceFlow>
    
    <userTask id="testProcessUserTask" name="userTask" flowable:formFieldValidation="true"></userTask>
    
     <sequenceFlow id="sid-24A278D9-3017-445D-ACDD-6AA62D031BAB" sourceRef="testProcessUserTask" targetRef="ref1"></sequenceFlow>
    
     <serviceTask id="ref1" flowable:type="dmn">
      <extensionElements>
        <flowable:field name="decisionTableReferenceKey">
          <flowable:string><![CDATA[decisionKey]]></flowable:string>
        </flowable:field>
        <flowable:field name="decisionTaskThrowErrorOnNoHits">
          <flowable:string><![CDATA[false]]></flowable:string>
        </flowable:field>
        <flowable:field name="fallbackToDefaultTenant">
          <flowable:string><![CDATA[false]]></flowable:string>
        </flowable:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="last" sourceRef="ref1" targetRef="sid-E6E6E7B2-6CC4-4042-BEC8-FDD37D22AB30"></sequenceFlow>
     
    
    <endEvent id="sid-E6E6E7B2-6CC4-4042-BEC8-FDD37D22AB30"></endEvent>
 
  </process>
 
</definitions>
  • Code source for test purpose in Java :

public class TestDMNTest {
static ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration().setJdbcUrl(
“jdbc:postgresql://localhost:5432/testdb”)
.setJdbcUsername(“postgres”)
.setJdbcPassword(“admin”)
.setJdbcDriver(“org.postgresql.Driver”)
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);

	static ProcessEngine processEngine = cfg.buildProcessEngine();


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


		RepositoryService repositoryService = processEngine.getRepositoryService();
		// Delete All deployement
		repositoryService.createDeploymentQuery().list().forEach(depl -> {
			repositoryService.deleteDeployment(depl.getId(), true);
		});

		Deployment deployment = repositoryService.createDeployment()
				.name("BpmnWithDmn")
				.addClasspathResource("BpmnWithDmn.bpmn20.xml")
				.deploy();

		ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
				.deploymentId(deployment.getId())
				.singleResult();


		RuntimeService runtimeService = processEngine.getRuntimeService();


		Map<String, Object> inputVariables = new HashMap<>();
		inputVariables.put("val1", "oum");

		ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess", inputVariables);

		List<Task> tasks = displayTasks(processInstance);

		FindAndTransitTo(inputVariables, tasks, "userTask");

	}

	private static List<Task> displayTasks(ProcessInstance processInstance) {
		List<Task> tasks = processEngine.getTaskService()
				.createTaskQuery()
				.processInstanceId(processInstance.getId())
				.list();
		System.out.println("You have " + tasks.size() + " tasks:");;
		for (int i = 0; i < tasks.size(); i++) {
			System.out.println(tasks.get(i).getId() + " " + (i + 1) + ") " + tasks.get(i).getName());

		}
		return tasks;
	}

	private static void FindAndTransitTo(Map<String, Object> variables, List<Task> tasks, String taskName) {
		try {
			Optional<Task> task = tasks.stream().filter(p -> p.getName().equals(taskName)).findFirst();
			if (task.isPresent()) {

				processEngine.getTaskService().complete(task.get().getId(), variables);
			}
		} catch (FlowableException e) {
			e.printStackTrace();
		}

	}
}

Cordially

Hi,

It looks like you’re not booting up the DMN engine and plugging it into the process engine.

Have a look here; https://github.com/flowable/flowable-engine/blob/master/docs/userguide/src/en/dmn/ch02-Configuration.adoc

(sections creating the engine and plug into Process Engine)

Did you also have a look writing tests using (Flowable) Spring Boot. This will take care of setting up the engines.

Regards,

Yvo

1 Like