This example demonstrates how to deploy a spring powered web application which
- Includes a
@ProcessApplication
class and some BPMN 2.0 processes - Starts a Spring Web application context based on a shared, container managed process engine
- Uses Spring Beans and delegation code in expressions within processes
This example shows how to combine a @ProcessApplication class
, a processes.xml
and a spring applicationContext into
a fully-fledged process application with all its advantages, including a shared, container managed process engine paired
with the power of Spring Beans inside your processes.
A process application class was created which extends the ServletProcessApplication
class. The class was annotated
with @ProcessApplication
. This allows the Camunda Platform to pick it up and register the process application
without any further action:
@ProcessApplication
public class SpringServletProcessApplication extends ServletProcessApplication {
...
}
Through the META-INF/processes.xml
, we can define process archives and additional options, like creating new engines
when deploying the process application:
<?xml version="1.0" encoding="UTF-8"?>
<process-application
xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.camunda.org/schema/1.0/ProcessApplication http://www.camunda.org/schema/1.0/ProcessApplication">
<process-archive>
<properties>
<property name="isDeleteUponUndeploy">true</property>
</properties>
</process-archive>
</process-application>
The scope attributes of the camunda-engine
dependency is set to provided since it is included in the shared classpath of the Camunda Tomcat distribution:
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
<version>${camunda.version}</version>
<scope>provided</scope>
</dependency>
The scope of camunda-engine-spring
, the module that integrates Camunda with Spring, must be set to compile
so that it is included in the application.
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
<version>${camunda.version}</version>
</dependency>
For testing, the Maven Cargo plugin unpacks the Camunda Tomcat distribution to the target/tomcat
directory of the application and runs it.
- Build it with Maven.
mvn clean verify
This will start the embedded tomcat server.
- Watch out for this console log:
[INFO] [talledLocalContainer] INFO: ENGINE-08046 Found Camunda Platform configuration in CATALINA_BASE/CATALINA_HOME conf directory [./target/cargo/configurations/tomcat9x/conf/bpm-platform.xml] at './target/cargo/configurations/tomcat9x/conf/bpm-platform.xml'
...
[INFO] [talledLocalContainer] INFO: ENGINE-07015 Detected @ProcessApplication class 'org.camunda.bpm.example.spring.servlet.pa.SpringServletProcessApplication'
[INFO] [talledLocalContainer] Sep 23, 2021 9:35:01 AM org.apache.catalina.core.ApplicationContext log
[INFO] [talledLocalContainer] INFO: Initializing Spring root WebApplicationContext
...
[INFO] [talledLocalContainer] INFO: Invoking @PostDeploy annotation in org.camunda.bpm.example.spring.servlet.pa.SpringServletProcessApplication
[INFO] [talledLocalContainer] Starting testResolveBean processdefinition
[INFO] [talledLocalContainer] Sep 23, 2021 9:35:01 AM org.camunda.bpm.example.spring.servlet.pa.ExampleBean invoke
[INFO] [talledLocalContainer] INFO: org.camunda.bpm.example.spring.servlet.pa.ExampleBean is currently invoked.
[INFO] [talledLocalContainer] Sep 23, 2021 9:35:01 AM org.camunda.bpm.example.spring.servlet.pa.SpringServletProcessApplication startProcess
[INFO] [talledLocalContainer] INFO: Starting testResolveBeanFromJobExecutor processdefinition
[INFO] [talledLocalContainer] Sep 23, 2021 9:35:01 AM org.camunda.bpm.example.spring.servlet.pa.ExampleDelegateBean execute
[INFO] [talledLocalContainer] INFO: org.camunda.bpm.example.spring.servlet.pa.ExampleDelegateBean is currently invoked.
[INFO] [talledLocalContainer] Sep 23, 2021 9:35:01 AM org.camunda.commons.logging.BaseLogger logInfo
[INFO] [talledLocalContainer] INFO: ENGINE-08050 Process application camunda-quickstart-spring-servlet-pa-tomcat successfully deployed