Skip to content

Spring ACL and native compilation fail to process datasource properties #12653

Closed
@RutgerLubbers

Description

@RutgerLubbers

Using Spring Boot 3, Spring 6, Java 17 and gradle, when performing a nativeCompile, the compilation fails in the processAot task:

...
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception with message: Failed to determine suitable jdbc url
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:171)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
        ... 87 more
...

It seems that the @ConfigurationProperties(prefix = "spring.datasource") is not processed in this case. Typically, when h2 is added to the classpath, then the error does not occur (no other changes required), however I suspect that the postgresql classes will not be present in the native build.

I would've expected the datasource to be present, so the JDBC connection can be used in the native image.

I've created a sample to see this behaviour, see https://github.com/RutgerLubbers/native-acl-jdbc

Metadata

Metadata

Labels

in: configAn issue in spring-security-configtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions