0

My Java Spring Boot project fails at startup with the given error:

Failed to instantiate [io.r2dbc.spi.ConnectionFactory]: Factory method 'connectionFactory' threw exception; nested exception is java.lang.NoSuchFieldError: LOCK_WAIT_TIMEOUT

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-r2dbc</artifactId>
        <version>1.4.3</version>
    </dependency>
    <dependency>
        <groupId>com.oracle.database.r2dbc</groupId>
        <artifactId>oracle-r2dbc</artifactId>
        <version>0.4.0</version>
    </dependency>

How do I fix it?

Alexander Taylor
  • 16,574
  • 14
  • 62
  • 83

1 Answers1

1

tl;dr: As of this writing, use oracle-r2dbc 0.1.0 in Spring projects.

oracle-r2dbc 0.4.0 depends on a newer version of io.r2dbc:r2dbc-spi than spring-data-r2dbc 1.4.3.

You may have to clear your build tool or IDE's cache for the change to take effect. (In my case mvn clean and IntelliJ "Invalidate Caches...")

Btw, when I downgraded, I think it broke using descriptors in the rdbc URL so I had to switch to a URL like this: r2dbc:oracle://<host>:<port>/<service-name>

Update, just saw on Oracle's driver docs for r2dbc, it says:

Use the 0.1.0 version of Oracle R2DBC if you are programming with Spring. The later versions of Oracle R2DBC implement the 0.9.x versions of the R2DBC SPI. Currently, Spring only supports drivers that implement the 0.8.x versions of the SPI.

https://github.com/oracle/oracle-r2dbc

DO NOT USE 0.2.0 with Spring - even worse than no error, queries just hang forever. I spent over a day trying to debug it. Not only I had the wrong version, but when I actually did try changing the version, my IDE was caching the old version out of sync with Maven.

Alexander Taylor
  • 16,574
  • 14
  • 62
  • 83