I decided to create a simple project to illustrate the issue. You may clone https://github.com/hernandezjd/camunda-example.git.
And run
./gradlew test
Everything should be ok and the one single test in the project should pass.
Then, if you go to build.gradle and change the version of Camunda from 7.11 to 7.12 and try again the test, you will get the error cause by the NullPointerException already described.
The project is a simple Java project that intends to be a library that uses a Camunda engine. The one single test just tries to inject the engine service and verifies it is available (not null):
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = TestConfiguration.class)
public class TestEngineService {
@Autowired
private EngineService engineService;
@Test
public final void testThatEngineServiceIsAvailable() {
assertNotNull(engineService);
}
}
EngineService is defined using a simple Spring service like this:
@Service
public class EngineService {
public EngineService(ProcessEngineFactoryBean processEngineFactoryBean) {
processEngineFactoryBean.getProcessEngineConfiguration().buildProcessEngine();
}
}
And the process engine configuration is pretty much the one written in all documentation and getting started manuals from Camunda:
@Configuration
public class EngineConfiguration {
private DataSource dataSource() {
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
dataSource.setDriverClass(org.h2.Driver.class);
dataSource.setUrl("jdbc:h2:mem:camunda;DB_CLOSE_DELAY=-1");
dataSource.setUsername("sa");
dataSource.setPassword("");
return dataSource;
}
private DataSourceTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource());
}
private SpringProcessEngineConfiguration processEngineConfiguration() {
SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
config.setDataSource(dataSource());
config.setTransactionManager(transactionManager());
config.setDatabaseSchemaUpdate("true");
config.setHistory("audit");
config.setJobExecutorActivate(true);
return config;
}
@Bean
public ProcessEngineFactoryBean processEngineFactoryBean() {
ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean();
factoryBean.setProcessEngineConfiguration(processEngineConfiguration());
return factoryBean;
}
}
This is the original build.gradle file, before switching to 7.12:
plugins {
id 'java'
id "io.spring.dependency-management" version "1.0.9.RELEASE"
}
sourceCompatibility = '1.8'
ext {
camunda_version = '7.11.0'
spring_version = '5.2.11.RELEASE'
}
dependencyManagement {
imports {
mavenBom "org.camunda.bpm:camunda-bom:${camunda_version}"
mavenBom "org.springframework:spring-framework-bom:${spring_version}"
}
}
dependencies {
repositories {
mavenCentral()
}
compile (group: 'org.camunda.bpm', name: 'camunda-engine')
compile (group: 'org.camunda.bpm', name: 'camunda-engine-spring')
compile (group: 'org.springframework', name: 'spring-context')
compile (group: 'org.springframework', name: 'spring-jdbc')
compile (group: 'org.springframework', name: 'spring-tx')
compile (group: 'org.springframework', name: 'spring-orm')
compile (group: 'com.h2database', name: 'h2', version: '1.4.196')
testCompile (group: 'junit', name: 'junit', version: '4.12')
testCompile (group: 'org.springframework', name: 'spring-test')
}
Any help for troubleshooting this issue will be much appreciated.
Thanks.