0

I am writing service based on Spring webflux, which reads data from PostgreSQL using r2dbc. I need to use latest release of r2dbc, however I am getting NoSuchMethodError exception in using TransactionSynchronizationManager spring-tx 5.2.0.RELEASE library.

I basically need to know what is correct spring-tx library version to be compatible with version of spring-data-r2dbc which works correctly with latest r2dbc-postgresql and r2dbc-spi libraries.

Here are my Maven dependencies.

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

<dependency>
          <groupId>org.springframework.data</groupId>
          <artifactId>spring-data-r2dbc</artifactId>
          <version>1.0.0.M2</version>
</dependency>

<dependency>
          <groupId>io.r2dbc</groupId>
          <artifactId>r2dbc-postgresql</artifactId>
          <version>0.8.0.RC2</version>
</dependency>

<dependency>
    <groupId>io.r2dbc</groupId>
    <artifactId>r2dbc-spi</artifactId>
    <version>0.8.0.M8</version>
</dependency>

I am using interface extending ReactiveCrudRepository interface to retrieve table data per below.

@Query("...")
Flux<QuoteHistory> findAllBySecIdAndDateTimeBetweenAndUpdateTypeIn(LocalDate date, Long secId);

I was able to get this code to work with earlier versions of r2dbc-postgresql and r2dbc-spi but now I am getting following exception.

java.lang.NoSuchMethodError: org.springframework.transaction.reactive.TransactionSynchronizationManager.currentTransaction()Lreactor/core/publisher/Mono; at org.springframework.data.r2dbc.connectionfactory.ConnectionFactoryUtils.doGetConnection(ConnectionFactoryUtils.java:88) ~[spring-data-r2dbc-1.0.0.M2.jar:1.0.0.M2] at org.springframework.data.r2dbc.connectionfactory.ConnectionFactoryUtils.getConnection(ConnectionFactoryUtils.java:70) ~[spring-data-r2dbc-1.0.0.M2.jar:1.0.0.M2] at org.springframework.data.r2dbc.core.DefaultDatabaseClient.getConnection(DefaultDatabaseClient.java:189) ~[spring-data-r2dbc-1.0.0.M2.jar:1.0.0.M2]

These are r2dbc dependencies which code works with.

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-r2dbc</artifactId>
    <version>1.0.0.M1</version>
</dependency>
<dependency>
    <groupId>io.r2dbc</groupId>
    <artifactId>r2dbc-postgresql</artifactId>
    <version>1.0.0.M7</version>
</dependency>

1 Answers1

0

Please use the following dependency combination:

  • R2DBC Postgres: 0.8.0.RC2
  • R2DBC SPI: 0.8.0.RC2
  • Spring Data R2DBC: 1.0.0.RC1
  • Spring Framework: 5.2.0.RELEASE

Alternatively, go to https://start.spring.io to get a dependency-managed project with versions that work together.

mp911de
  • 17,546
  • 2
  • 55
  • 95
  • I have to use R2DBC Postgres: 0.8.0.RC2 because just added support for JSONB so I will need to use Spring Framework where currently I rely on Spring Boot libraries to start the app and import WebFlux components. Having a bit of a problem pulling required WebFlux libraries from Spring Framework dependencies to make app start Netty properly. – John Bradsow Oct 31 '19 at 19:08