I am no longer using Spring boot and have started over by following the tutorial for Spring at https://docs.camunda.org/get-started/spring/ (first 3 sections). The tutorial works as expected.
Now I want to split the war into 2 separate wars. The first war is to be the shared process engine while the second is to be just the LoanApplication process to be deployed independently on the same Tomcat server.
I can deploy and run the first war (the shared process engine) and verify it is running. However the second war (the LoanApplication process) is not recognized when I deploy it. I’m obviously missing some key step.
Here is the camunda config in the first war’s pom (the shared process engine):
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-spring</artifactId>
</dependency>
And the Spring context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd" >
<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<property name="targetDataSource">
<bean class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="org.h2.Driver" />
<property name="url"
value="jdbc:h2:mem:process-engine;DB_CLOSE_DELAY=1000" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
<property name="processEngineName" value="engine" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
<property name="deploymentResources" value="classpath*:*.bpmn" />
</bean>
<bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
<context:annotation-config />
</beans>
The second war (LoanApproval) was initially built using the camunda-archetype=servlet-war and contains the LoanApproval.bpmn and CalculateInterestService (both from the tutorial) as wall as this processes.xml:
<?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">
<process-archive>
<process-engine>default</process-engine>
<properties>
<property name="isDeleteUponUndeploy">false</property>
<property name="isScanForProcessDefinitions">true</property>
</properties>
</process-archive>
</process-application>
And this is the camunda reference in the LoanApproval war’s pom.xml:
<dependency>
<!-- process engine, needs to be provided -->
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
<scope>provided</scope>
</dependency>
The Tomcat server log does not indicate any errors with either of the war deployments.
In my shared process server (the first war), I have defined this rest api to get process definitions, none are found after deploying the LoanApplication process’ war.
package com.vi.intel.smartserver;
import com.google.gson.Gson;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.RepositoryService;
import org.camunda.bpm.engine.repository.ProcessDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class RestApi {
@Autowired
private ProcessEngine processEngine;
private Gson gson = new Gson();
@RequestMapping(value = "/api/processDefs", method = RequestMethod.GET)
@ResponseBody
public String processDefs() {
RepositoryService processEngineServices = processEngine.getRepositoryService();
// query for latest process definition with given name
List<ProcessDefinition> processDefinitions =
processEngineServices.createProcessDefinitionQuery().list();
return gson.toJson(processDefinitions);
}
}