-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Spring ACL and native compilation fail to process datasource properties #12653
Comments
Hi @RutgerLubbers, since that is a Spring Boot application, can't you let Spring Boot create the DataSource for you instead? |
Hi @marcusdacoregio , If native compilation is disabled, then In the example the datasource is defined in the The example does a native compilation which results in an error, so doing a Adding the So, the issue is, why does native compilation fail (without H2)? (Where I say "bootRun", this also goes for "compileNative", only native compilation without the native compilation plugin fails ;-)) |
Generally speaking, beans shouldn't be created during AOT processing as it's only bean definitions that are important. There are a few exceptions, for example
The link between |
Hi @RutgerLubbers, thanks for the report. I tried the latest version of your repository and it seems that the error is not happening in Spring Boot 3.1.1. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Hi @marcusdacoregio , sorry, I left the sample in a state where it did work (it included the H2 database), so building did not trigger the error. I've updated the build file to include all latest versions and the sample now triggers the erroneous behaviour. |
Hi, @RutgerLubbers. Sorry for the delay on this. The reason why it works when adding the H2 dependency is because the Based on @wilkinsona comment, I think the best option here is to defer the initialization of the I'll reach out to @jzheaux to make sure that there are no obvious side-effects on doing that and then I'll push a fix. |
When using Spring Security ACL and compiling to Native, in order to create the '*AuthorizationMethodInterceptor' Proxy beans during build time, Spring tries to resolve the DataSource bean since the DataSource can be a dependency of some AclService implementations, and fails because some required data source properties are not available during build time. This commit defers the initialization of the MethodSecurityExpressionHandler to the runtime. Closes spring-projectsgh-12653
Thanks Marcus, Andy! (and others?) |
Using Spring Boot 3, Spring 6, Java 17 and gradle, when performing a
nativeCompile
, the compilation fails in theprocessAot
task: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
The text was updated successfully, but these errors were encountered: