Unresolvable conflict with Spring-Boot-Starter and Postgres

Hi there,

I wanted my Camunda Engine to use a Postgres database. According to the docs and some topics in the forum, I added a yaml-File with this contents:

spring.datasource:
  url: jdbc:postgresql://localhost:5432/xxx
  driverClassName: org.postgresql.Driver
  username: yyy
  password: zzz
camunda.bpm:
  database:
    schema-update: false
    type: postgres

When I started my SpringBootApp, it stopped with an error message that the database tables were missing. So I changed schema-update from false to true. Now the tables were found, but they were really created, e.q. a new user I had added was lost.

The solution out of this was to add a dependency on spring-boot-start-jdbc. But with this, only the first bpmn test passes. All following tests are interrupted by this exception:

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:305)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:378)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:137)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:44)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.engine.impl.AbstractQuery.executeResult(AbstractQuery.java:159)
at org.camunda.bpm.engine.impl.AbstractQuery.singleResult(AbstractQuery.java:135)
at org.camunda.bpm.engine.test.assertions.bpmn.TaskAssert.getCurrent(TaskAssert.java:43)
at org.camunda.bpm.engine.test.assertions.bpmn.TaskAssert.getCurrent(TaskAssert.java:31)
at org.camunda.bpm.engine.test.assertions.bpmn.AbstractProcessAssert.getExistingCurrent(AbstractProcessAssert.java:66)
at org.camunda.bpm.engine.test.assertions.bpmn.TaskAssert.hasCandidateGroup(TaskAssert.java:108)
at org.camunda.bpm.engine.test.assertions.bpmn.TaskAssert.hasCandidateGroup(TaskAssert.java:90)
at com.innogy.flink.operation.flink2019.monitoring.bpmn.ResourceNumEntriesResourceTest.limitExceededNoRetry(ResourceNumEntriesResourceTest.java:197)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:262)
… 44 more

Has anybody an idea how I can get out of this conflict?

many thanks
Christian

Hi @cjacob,

Have you added the following dependency in your Spring Boot project?

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
    <version>${spring.boot.version}</version>
</dependency>

This is usually the culprit for an exception like the one you provided.

Best,
Nikola

Hi Nikola,
thanks for your help. Yes, I’ve added this dependency. But I had to because without it the database tables in Postgres were not generated. I also had tried to generate them by hand. But when I did that and started the Spring Boot App with the parameter

camunda.bpm.database.schema-upadate: false

, the app did not start and complained that the database tables would not exist. And if I started it with

camunda.bpm.database.schema-update: true

the tables were deleted and rebuilt. So all old informations were lost. That was really painful.

schema-update false did only work as expected with this maven dependency. But then, the tests failed. So this seems to me a not resolvable conflict.

Regaurds
Christian