Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Spring Boot application fails to start when using MySql R2DBC driver

Open
#292 0 comments 0 reactions 0 assignees View on GitHub

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

bug
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
  1. Create spring web flux application which uses MySql and r2dbc (Sorry, I don't have time to provide working example)
  2. 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pivotal-cf/java-cfenv

All issues in pivotal-cf/java-cfenv

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.