[io.r2dbc.spi.ConnectionFactory]: java.lang.NoSuchFieldError: LOCK_WAIT_TIMEOUT

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?

1 Answer

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.

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.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like