Prev Next

DMN Module Code Generation and Test Module

After a Decision Model is created and simulated, you can generate a DMN Module in Java, JavaScript, C++ or C#. The DMN Module can be used with the Enterprise Architect BPSim Execution Engine, Executable StateMachine, or your own project.

Enterprise Architect also provides a 'Test Module' page, which is a preprocess for integrating DMN with BPMN. The concept is to provide one or more BPMN2.0::DataObject elements, then test if a specified target decision can be evaluated correctly or not.

If any error or exception occurs, you can create an Analyzer Script to debug the code of the DMN Module and Test Client.

After this 'Test Module' process, Enterprise Architect guarantees that the BPMN2.0::DataObject elements will work well with the DMN Module.

You then configure BPSim by loading DataObjects and assigning DMN Module decisions to BPSim Properties, which will be further used as conditions on the Sequence Flows outgoing from a Gateway.

DMN Module: Code Generation

Activate the 'Generate Module' tab of the DMN Simulation window, select the DMN elements you want to generate to the server, specify the file path and language, then click on the Generate button.

(Note: For Java, the path has to match the Package structure.)

  • Add the elements to the module, then click on the Add button on the toolbar to open the 'DMN Element Selection' dialog

A view of the dialog for selecting the Elements to be included in code generation of a DMN module Sparx Systems Enterprise Architect.

  • Click on the decision you want to generate to the server; in this example we select the decision 'Application risk score'

Note: All the dependencies will be selected automatically.

A view of the dialog for selecting the Elements to be included in code generation of a DMN module Sparx Systems Enterprise Architect.

  • Generate the DMN Module; give the Java file a Package name, then click on the Generate button

Setting the module path ready for the Java code generation of a DMN model using Sparx Systems Enterprise Architect.

Note: In this example, the Module Path ends with '\com\sparxsystems\dmn', which matches the Package 'com.sparxsystems.dmn'.

  • Click on the Test button to access the 'Test Server' page

DMN Server: Test client

If this page was activated from the 'Generate Server' page, the 'DMN Module' field will be filled automatically with the generated DMN Server's path. Otherwise, click the Browse. button to browse for a DMN Server file.

Click the Add DataObject button to add one or more BPMN2.0 DataObject(s) to the list, choose a decision from the combo box, then click the Run button on the toolbar.

Adding BPMN DataObjects to a DMN simulation's Test Module using Sparx Systems Enterprise Architect.

In the System Output window, this message indicates the DMN Server and BPMN2.0 DataObject can work well with each other to evaluate the selected decision.

Running Test Client for DMN Server...

    dmnServer.Application_risk_score: 133.0

Result : 133.0

The Running completed successfully.

If there are errors, create an Analyzer script by clicking the toolbar button and fix the issue.

Important: This 'Test Module' step is recommended before integrating to the Enterprise Architect BPSim Execution Engine.

Code Generation & Connect to BPMN

  • Generate the DMN Server in Java, JavaScript, C++, or C#
  • Run/Debug testing of the Java version of the DMN Server
  • Connect the DMN Server with the Enterprise Architect BPSim Execution Engine

Common Errors & Solutions

  • Variable Types: as DMN models use the FEEL language (Simulate with JavaScript), typing variables is not compulsory; however, when generating code to languages that are compiled, you do have to type a variable - there are context menu options and tag values for setting the type of a variable
  • Since a DMN expression allows for spaces, in order to clarify the composite Input Data there must be a space before and after the '.' in the expression; for example, 'Applicant data . Age' is valid, whereas 'Applicant data.Age' is not valid
    Note that when using the Auto Completion feature this issue will not arise
  • 'Run validation' will help you locate most of the modeling issues; run this before simulation and code generation


  • Compiling with Java requires full read-write access to the target directory. Compilation will fail if the module path is set to 'C:' or 'C:\Progam Files (x86)'