Skip to content

Add native hint for the users JDBC schema #11907

@willemvd

Description

@willemvd

Describe the bug
When using Spring Boot 3.0.0-M5 to build a native application with the ./mvnw -Pnative package and the auth.jdbcAuthentication().withDefaultSchema() option set on the JdbcUserDetailsManagerConfigurer, the application is compiled as native application but gives a runtime exception.
The exception is:
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/security/core/userdetails/jdbc/users.ddl] cannot be opened because it does not exist

This seems to be related to the https://github.com/spring-projects/spring-security/blob/main/core/src/main/java/org/springframework/security/aot/hint/CoreSecurityRuntimeHints.java which is missing the DDL schema as resource. This causes GraalVM to not include the DDL schema when building the native application.

Leaving out the .withDefaultSchema() part, the application is starting without issues.

To Reproduce
Start a Spring Boot 3.0.0-M5 application and include the Spring Security module.
Add a Bean configuration which returns the UserDetailsManger created from the AuthenticationManagerBuilder. Set it with:
return auth.jdbcAuthentication().withDefaultSchema().getUserDetailsService()

Expected behavior
The application should start with loading the default schema, into the datasource given, when configured using the .withDefaultSchema() option.

Sample
https://github.com/willemvd/jdbc-security-default-schema-native

Metadata

Metadata

Labels

in: coreAn issue in spring-security-coretype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions