Spring Boot transactionManager error when using Postgres

Hi All

For the Camunda Spring Boot example-web

I tried using Postgres as the DB. Using H2 works without any issues!

Seeing the following error

Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name ‘servletEndpointRegistrar’ defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method ‘servletEndpointRegistrar’ threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘healthEndpoint’ defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthEndpoint]: Factory method ‘healthEndpoint’ threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.camunda.bpm.engine.spring.SpringProcessEngineServicesConfiguration’: Unsatisfied dependency expressed through field ‘processEngine’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.camunda.bpm.spring.boot.starter.CamundaBpmAutoConfiguration$ProcessEngineConfigurationImplDependingConfiguration’: Unsatisfied dependency expressed through field ‘processEngineConfigurationImpl’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘processEngineConfigurationImpl’ defined in class path resource [org/camunda/bpm/spring/boot/starter/CamundaBpmConfiguration.class]: Unsatisfied dependency expressed through method ‘processEngineConfigurationImpl’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘camundaDatasourceConfiguration’: Unsatisfied dependency expressed through field ‘transactionManager’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘org.springframework.transaction.PlatformTransactionManager’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


APPLICATION FAILED TO START


Description:

Field transactionManager in org.camunda.bpm.spring.boot.starter.configuration.impl.DefaultDatasourceConfiguration required a bean of type ‘org.springframework.transaction.PlatformTransactionManager’ that could not be found.
- Bean method ‘transactionManager’ not loaded because @ConditionalOnSingleCandidate (types: javax.sql.DataSource; SearchStrategy: all) did not find any beans

Action:

Consider revisiting the conditions above or defining a bean of type ‘org.springframework.transaction.PlatformTransactionManager’ in your configuration.

Works fine with Camunda (7.8) SB starter 2.3.0.
Any suggestions?

My configuration is;

application.properties

spring.datasource.url=jdbc:postgresql://localhost:5432/camunda
spring.datasource.username=camunda
spring.datasource.password=camunda
spring.datasource.driver-class-name=org.postgresql.Driver

pom.xml

<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>42.2.2</version>
</dependency>

Regards
Tom.

1 Like

Hi @tomconnolly,

have a look at this post: Camunda-spring-boot-starter ignores spring-datasource.url pointing to h2 file based

It helps for H2 and I think it would help for PostgresQL, too.

Cheers, Ingo

3 Likes

Thanks @Ingo_Richtsmeier, that was the issue.

Just added the following dependency and picked up the postgres database

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

Again thank you for the solution.

2 Likes