Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsupportedDataSourcePropertyException is thrown when attempting to set driverClassName for H2 #26631

Closed
whiskeysierra opened this issue May 21, 2021 · 2 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@whiskeysierra
Copy link

After upgrading to 2.5.0, this data source configuration:

spring:
  datasource:
    type: org.h2.jdbcx.JdbcDataSource
    url: jdbc:h2:mem:database
    username: sa
    password: password

fails with the following exception:

Caused by: org.springframework.boot.jdbc.UnsupportedDataSourcePropertyException: No mapping found for driverClassName
	at org.springframework.boot.jdbc.UnsupportedDataSourcePropertyException.throwIf(UnsupportedDataSourcePropertyException.java:36) ~[spring-boot-2.5.0.jar:2.5.0]
	at org.springframework.boot.jdbc.DataSourceBuilder$MappedDataSourceProperties.getMapping(DataSourceBuilder.java:344) ~[spring-boot-2.5.0.jar:2.5.0]
	at org.springframework.boot.jdbc.DataSourceBuilder$MappedDataSourceProperties.set(DataSourceBuilder.java:332) ~[spring-boot-2.5.0.jar:2.5.0]
	at org.springframework.boot.jdbc.DataSourceBuilder.build(DataSourceBuilder.java:179) ~[spring-boot-2.5.0.jar:2.5.0]
	at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Generic.dataSource(DataSourceConfiguration.java:150) ~[spring-boot-autoconfigure-2.5.0.jar:2.5.0]
	at jdk.internal.reflect.GeneratedMethodAccessor66.invoke(Unknown Source) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.7.jar:5.3.7]
	... 87 common frames omitted

I took a quick look and it seems like the H2DataSourceProperties only supports three properties:

	private static class H2DataSourceProperties extends MappedDataSourceProperties<JdbcDataSource> {

		H2DataSourceProperties() {
			add(DataSourceProperty.URL, JdbcDataSource::getUrl, JdbcDataSource::setUrl);
			add(DataSourceProperty.USERNAME, JdbcDataSource::getUser, JdbcDataSource::setUser);
			add(DataSourceProperty.PASSWORD, JdbcDataSource::getPassword, JdbcDataSource::setPassword);
		}

	}

The driverClassName is not supported, but it will be set by DataSourceProperties#initializeDataSourceBuilder:

	public DataSourceBuilder<?> initializeDataSourceBuilder() {
		return DataSourceBuilder.create(getClassLoader()).type(getType()).driverClassName(determineDriverClassName())
				.url(determineUrl()).username(determineUsername()).password(determinePassword());
	}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 21, 2021
@snicoll snicoll added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels May 21, 2021
@snicoll snicoll added this to the 2.5.1 milestone May 21, 2021
@snicoll
Copy link
Member

snicoll commented May 21, 2021

Thanks for the report. I believe this is a regression that may have been introduced by #25643

@scottfrederick scottfrederick changed the title UnsupportedDataSourcePropertyException: No mapping found for driverClassName UnsupportedDataSourcePropertyException is thrown when attempting to set driverClassName for H2 May 24, 2021
@scottfrederick scottfrederick self-assigned this May 24, 2021
@snicoll
Copy link
Member

snicoll commented May 25, 2021

Postgres and Oracle are impacted in a similar fashion, I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

5 participants