Spring Boot application fails to start when using MySql R2DBC driver
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java, mysql, spring-boot
Research direction
Start with MySqlJdbcUrlCreator.java, especially getDriverClassName() and createJdbcUrl(), then trace how CfJdbcUrlCreator and CfJdbcEnv are invoked by CfDataSourceEnvironmentPostProcessor. Reproduce the Spring WebFlux deployment with MySQL R2DBC on PCF if possible; done means the application starts without the reported NullPointerException and CfEnv supports the reactive-driver case.
Written by the indexing model from the issue text.
Description
Describe the bug
I’m trying to use the reactive MySQL driver instead of JDBC, and CfEnv has logic to identify which driver is being used, MySQL or MariaDB. It relies on the presence of specific JDBC drivers in the classpath. Since I’m using R2DBC, it doesn’t find any drivers and later trows an NPE, as a result the application fails to start.
20:12:37.561 [main] ERROR org.springframework.boot.SpringApplication -- Application run failed
java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "io.pivotal.cfenv.jdbc.MySqlJdbcUrlCreator.getDriverClassName()" is null
at io.pivotal.cfenv.jdbc.MySqlJdbcUrlCreator.createJdbcUrl(MySqlJdbcUrlCreator.java:81)
at io.pivotal.cfenv.jdbc.CfJdbcUrlCreator.<init>(CfJdbcUrlCreator.java:45)
at io.pivotal.cfenv.jdbc.CfJdbcEnv.findJdbcServices(CfJdbcEnv.java:34)
at io.pivotal.cfenv.spring.boot.CfDataSourceEnvironmentPostProcessor.postProcessEnvironment(CfDataSourceEnvironmentPostProcessor.java:75)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:132)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:115)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
at java.base/java.lang.Iterable.forEach(Unknown Source)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:353)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350)
at com.example.Application.main(Application.java:24)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:102)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)
Exit status 1
Reproduction steps
- Create spring web flux application which uses MySql and r2dbc (Sorry, I don't have time to provide working example)
- Deploy to PCF
Expected behavior
CfEnv supports r2dbc
Additional context
As a work-around I added jdbc driver to the classpath for now.
- Dominant language
- Java
- Stars
- 97
- Forks
- 64
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pivotal-cf/java-cfenv
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
pivotal-cf/java-cfenv#354 · 1 reaction ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 48/100
pivotal-cf/java-cfenv#296 · 3 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
pivotal-cf/java-cfenv#255 · 2 comments ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
pivotal-cf/java-cfenv#249 · 2 comments ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
pivotal-cf/java-cfenv#171 · 1 comment ·
All issues in pivotal-cf/java-cfenv
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
redhat-developer/intellij-quarkus#1626 ·
-
Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/product-integrator-mi#5061 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
quarkiverse/quarkus-roq#1277 ·
Maintainers usually reply within 1 day
-
Typos in page footerOpen
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/logging-site#48 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/maven-surefire#3496 · 3 comments ·
Maintainers usually reply within 1 day