Instantiate a CMMN Case Definition

In this step, we use Java code to instantiate the case definition, then deploy and test the application.

Java Code

To directly create a case instance after deployment, add the following method to your LoanApprovalApplication class:


package org.camunda.bpm.getstarted.cmmn.loanapproval;

import org.camunda.bpm.application.PostDeploy;
import org.camunda.bpm.application.ProcessApplication;
import org.camunda.bpm.application.impl.ServletProcessApplication;
import org.camunda.bpm.engine.CaseService;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.variable.Variables;

@ProcessApplication("Loan Approval App CMMN")
public class LoanApprovalApplication extends ServletProcessApplication {

  @PostDeploy
  public void startCaseInstance(ProcessEngine processEngine) {
    CaseService caseService = processEngine.getCaseService();
    caseService.createCaseInstanceByKey("loan_application",
        Variables.createVariables()
          .putValue("applicationSufficient", Variables.booleanValue(null))
          .putValue("rating", Variables.integerValue(null)));

  }
}

Build the Web Application with Maven

A Process Application is an ordinary Java Web Application and is deployed in exactly the same way.

Select the pom.xml in the Package Explorer, perform a right-click and select Run As / Maven Clean and afterwards Run As / Maven Install. This will generate a WAR file named loan-approval-cmmn-0.1.0-SNAPSHOT.war in the target/ folder of your Maven project.

Hint

If the loan-approval-cmmn-0.1.0-SNAPSHOT.war file is not visible after having performed the Maven build, you need to refresh the project (F5) in Eclipse.

Deploy to Apache Tomcat

To deploy the process application, copy-paste the loan-approval-cmmn-0.1.0-SNAPSHOT.war from your Maven project to the $CAMUNDA_HOME/server/apache-tomcat/webapps folder.

Check the log file of the Apache Tomcat server in the $CAMUNDA_HOME/server/apache-tomcat/logs folder. Select the file with the name catalina.out. Scroll to the end of the file and if you see the following log message, the deployment was successful:

INFO org.apache.catalina.startup.HostConfig.deployWAR
Deploying web application archive ...\webapps\loan-approval-cmmn-0.1.0-SNAPSHOT.war
INFO org.camunda.commons.logging.BaseLogger.logInfo
ENGINE-07015 Detected @ProcessApplication class 'org.camunda.bpm.getstarted.cmmn.loanapproval.LoanApprovalApplication'
INFO org.camunda.commons.logging.BaseLogger.logInfo
ENGINE-08024 Found processes.xml file at .../webapps/loan-approval-cmmn-0.1.0-SNAPSHOT/WEB-INF/classes/META-INF/processes.xml
INFO org.camunda.commons.logging.BaseLogger.logInfo
ENGINE-08023 Deployment summary for process archive 'loan-approval-cmmn':

        loan-approval.cmmn11.xml

INFO org.camunda.commons.logging.BaseLogger.logInfo
ENGINE-08050 Process application Loan Approval App CMMN successfully deployed
INFO org.apache.catalina.startup.HostConfig.deployWAR
Deployment of web application archive ...\webapps\loan-approval-cmmn-0.1.0-SNAPSHOT.war has finished in 1,335 ms

Verify the Deployment with Camunda Tasklist

Now use Camunda Tasklist to check if the case was instantiated. Go to Camunda Tasklist (http://localhost:8080/camunda/app/tasklist).

Log in with demo / demo. After you have logged in, click on the filter My Tasks. There should be two tasks listed with names Check Application and Provide Customer Rating. Select the task Check Application.

The Tasklist displays a generic form that can be used whenever you have not added a dedicated form for a Human Task. You can use it to add variables to the case. For now, we leave it empty. Just click .

Do the same with the task Provide Customer Rating. Both tasks have now completed and there is no more work to be done in this case instance.

Catch up: Get the Sources of Step-4.

Download as .zip or checkout the corresponding tag with Git.

You can checkout the current state from the GitHub repository.

If you have not cloned the repository yet, please execute the following command:

git clone https://github.com/camunda/camunda-get-started-cmmn.git

To checkout the current state of the process application please execute the following command:

git checkout -f Step-4
Or download as archive from here.

On this Page: