I am trying to set up R2DBC for my Spring Boot app which has Oracle 19c as the database and configured with OJDBC8 and Java 11. R2DBC version is 0.1.0. I'm getting following error as the application fails to start. Does rRDBC work with Oracle 19c or does it need to be Oracle 21x?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myr2dbccon': Unexpected exception during bean creation; nested exception is io.r2dbc.spi.R2dbcNonTransientResourceException: Unsupported Oracle JDBC Driver version: 19
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.9.jar!/:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.9.jar!/:5.3.9]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:64) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.2.jar!/:2.5.2]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
Caused by: io.r2dbc.spi.R2dbcNonTransientResourceException: Unsupported Oracle JDBC Driver version: 19
at oracle.r2dbc.impl.ReactiveJdbcAdapter.getOracleAdapter(ReactiveJdbcAdapter.java:92) ~[oracle-r2dbc-0.1.0.jar!/:0.1.0]
at oracle.r2dbc.impl.OracleConnectionFactoryImpl.<init>(OracleConnectionFactoryImpl.java:120) ~[oracle-r2dbc-0.1.0.jar!/:0.1.0]
at oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl.create(OracleConnectionFactoryProviderImpl.java:93) ~[oracle-r2dbc-0.1.0.jar!/:0.1.0]
at io.r2dbc.spi.ConnectionFactories.find(ConnectionFactories.java:112) ~[r2dbc-spi-0.8.5.RELEASE.jar!/:?]
at io.r2dbc.spi.ConnectionFactories.get(ConnectionFactories.java:142) ~[r2dbc-spi-0.8.5.RELEASE.jar!/:?]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1231) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.9.jar!/:5.3.9]
CodePudding user response:
The error is about the Oracle JDBC driver version, not about your Oracle version. The Oracle R2DBC driver relies on specific features in the Oracle JDBC driver, and those features are only available in newer driver versions, and then only in the Java 11 (or higher) version of the driver (i.e. ojdbc11, not ojdbc8).
According to https://github.com/oracle/oracle-r2dbc, the latest Oracle R2DBC driver requires the Oracle JDBC 21.3 driver.
It also says:
The Oracle R2DBC Driver has been verified with Oracle Database versions 18, 19, and 21.
To be clear, the Oracle JDBC 21.3 driver works fine with Oracle 19c, and so does R2DBC.
In short, you need to update your Oracle JDBC driver to:
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>21.3.0.0</version>
</dependency>