make AOT hints for ELC optional#3267
Merged
sothawo merged 1 commit intospring-projects:mainfrom Mar 30, 2026
Merged
Conversation
`spring-data-elasticsearch` is also being pulled in as a dependency of `spring-data-opensearch`. the latter excludes the transient ELC dependency since it doesn't need it. if `spring-data-opensearch` (or any downstream project) wants to use AOT then spring will automatically also pick up the AOT hints from `spring-data-elasticsearch` - but so far these reference the ELC classes which have been excluded by `spring-data-opensearch`, thus resulting in a `ClassNotFoundException`. this commit makes the registration of these hints dependent on the presence of the ELC on the classpath. this has no impact on `spring-data-elasticsearch` consumers which already make use of AOT but unblocks the usage of AOT for `spring-data-opensearch` and its consumers. see also opensearch-project/spring-data-opensearch#441 Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com>
cd2dca2 to
e4b7f62
Compare
rursprung
added a commit
to rursprung/spring-data-opensearch
that referenced
this pull request
Mar 26, 2026
this registers the necessary hints for [Ahead-of-Time Processing] to support both AOT and [GraalVM Native Image] usage. it also modifies one example application so that it can - optionally - be run as a native image to show that it works. this is also used in CI to test that it still builds. on its own this will fail since by using AOT we automatically also pull in the AOT hints registered in `spring-data-elasticsearch` which in turn currently unconditionally registers hints for the Elasticsearch Client (ELC) which we however exclude as a transient dependency. thus a PR has been raised to make this optional: spring-projects/spring-data-elasticsearch#3267 this will have to be merged & released first for this PR to work. i have however verified things locally (though admittedly on the previous major release since i only had GraalVM 21 at hand and SB 4.x requires GraalVM 25). resolves opensearch-project#411 [Ahead-of-Time Processing]: https://docs.spring.io/spring-boot/reference/packaging/aot.html [GraalVM Native Image]: https://docs.spring.io/spring-boot/reference/packaging/native-image/index.html
rursprung
added a commit
to rursprung/spring-data-opensearch
that referenced
this pull request
Mar 26, 2026
this registers the necessary hints for [Ahead-of-Time Processing] to support both AOT and [GraalVM Native Image] usage. it also modifies one example application so that it can - optionally - be run as a native image to show that it works. this is also used in CI to test that it still builds. on its own this will fail since by using AOT we automatically also pull in the AOT hints registered in `spring-data-elasticsearch` which in turn currently unconditionally registers hints for the Elasticsearch Client (ELC) which we however exclude as a transient dependency. thus a PR has been raised to make this optional: spring-projects/spring-data-elasticsearch#3267 this will have to be merged & released first for this PR to work. i have however verified things locally (though admittedly on the previous major release since i only had GraalVM 21 at hand and SB 4.x requires GraalVM 25). resolves opensearch-project#411 [Ahead-of-Time Processing]: https://docs.spring.io/spring-boot/reference/packaging/aot.html [GraalVM Native Image]: https://docs.spring.io/spring-boot/reference/packaging/native-image/index.html Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com>
5 tasks
rursprung
added a commit
to rursprung/spring-data-opensearch
that referenced
this pull request
Mar 26, 2026
this registers the necessary hints for [Ahead-of-Time Processing] to support both AOT and [GraalVM Native Image] usage. it also modifies one example application so that it can - optionally - be run as a native image to show that it works. this is also used in CI to test that it still builds. on its own this will fail since by using AOT we automatically also pull in the AOT hints registered in `spring-data-elasticsearch` which in turn currently unconditionally registers hints for the Elasticsearch Client (ELC) which we however exclude as a transient dependency. thus a PR has been raised to make this optional: spring-projects/spring-data-elasticsearch#3267 this will have to be merged & released first for this PR to work. i have however verified things locally (though admittedly on the previous major release since i only had GraalVM 21 at hand and SB 4.x requires GraalVM 25). `ElasticsearchClientAutoConfiguration` also needs to be excluded in the `MarketplaceApplication` since otherwise two `JacksonJsonpMapper` beans will be present and the application will fail to start in the `processAot` phase. resolves opensearch-project#411 [Ahead-of-Time Processing]: https://docs.spring.io/spring-boot/reference/packaging/aot.html [GraalVM Native Image]: https://docs.spring.io/spring-boot/reference/packaging/native-image/index.html Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com>
Contributor
Author
|
CC @reta, @dlvenable, @andrross: this is needed for opensearch-project/spring-data-opensearch#638 |
sothawo
approved these changes
Mar 30, 2026
Contributor
|
Thanks a lot @sothawo ! |
Contributor
Author
|
thanks a lot @sothawo! do you see a chance to cherry-pick this to the 6.0.x branch (and get a fresh release off of there) so that we could already use it with Spring Boot 4.0.x rather than having to wait for SB 4.1.0? |
Collaborator
|
Thought you would ask that. Backported. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
spring-data-elasticsearchis also being pulled in as a dependency ofspring-data-opensearch. the latter excludes the transient ELC dependency since it doesn't need it.if
spring-data-opensearch(or any downstream project) wants to use AOT then spring will automatically also pick up the AOT hints fromspring-data-elasticsearch- but so far these reference the ELC classes which have been excluded byspring-data-opensearch, thus resulting in aClassNotFoundException.this commit makes the registration of these hints dependent on the presence of the ELC on the classpath. this has no impact on
spring-data-elasticsearchconsumers which already make use of AOT but unblocks the usage of AOT forspring-data-opensearchand its consumers.see also opensearch-project/spring-data-opensearch#441
closes #3268
spring-data-opensearchwith which i've tested this