-
Notifications
You must be signed in to change notification settings - Fork 21
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
Constructor autowiring AOP broken when running build-image with JLink #432
Comments
Something else to try, that I should have mentioned earlier, is to try using JLink locally so that buildpacks aren't involved. That would help to further narrow down the likely cause. |
+1 to what @wilkinsona suggested. Run the same commands outside of buildpacks and see if you also have issues. The buildpack is just automating the run of It'll do this:
If that is removing too much stuff for your app, you can change what is removed by setting Hope that helps! |
You're right! Buildpacks itself is not the problem, but JLink with insufficient modules is! jlink --no-man-pages --no-header-files --strip-debug --compress=1 --add-modules "$(java --list-modules | grep '^java' | sed 's/@21.0.5//' | paste -s -d, -)" --output /tmp/jre
java -jar target/buildpacks-1.0.0-SNAPSHOT.jar Also displays the same problem. I've gradually included more Try running rm -rf /tmp/jre && jlink --no-man-pages --no-header-files --strip-debug --compress=1 --add-modules "$(java --list-modules | grep '^java' | sed 's/@21.0.5//' | paste -s -d, -)" --output /tmp/jre && /tmp/jre/bin/java -jar target/buildpacks-0.0.1-SNAPSHOT.jar vs rm -rf /tmp/jre && jlink --no-man-pages --no-header-files --strip-debug --compress=1 --add-modules "$(java --list-modules | grep '^java' | sed 's/@21.0.5//' | paste -s -d, -),jdk.unsupported" --output /tmp/jre && /tmp/jre/bin/java -jar target/buildpacks-0.0.1-SNAPSHOT.jar I understand that including JDK modules is not intended by default. Most Java applications probably do not need that level of runtime manipulation. The question now remains is, is this an issue? Should Personally I am glad to have a workaround and know what the problem is, but having this case work out of the box would be nice, as it is not directly obvious from the error messages what the issue is. |
Hey, that's great you got to the bottom of this and thanks for sharing your findings.
Thanks |
This has been first reported in spring-projects/spring-boot#42771, but I was asked to report the bug here.
When creating a Spring Boot application using
spring-boot:build-image
while also enabelingBP_JVM_JLINK_ENABLED
, any constructor autowriting on components that are annotated with@Repository
will throw an exception on startup. This only happens when JLink is enabled and specifically the@Repository
stereotype annotation is used.@Component
does not present the same issue.A reproduction for this problem can be found here: https://github.com/SanderKnauff/buildpack-aop-jlink-broken
Expected Behavior
Startup should finish properly and all CGLib generated classes should contain their generated constructors, so Objenesis can create instances.
Current Behavior
The following exception occurs at startup:
Possible Solution
N/A
Steps to Reproduce
./mvnw -DskipTests package spring-boot:process-aot spring-boot:build-image
docker run buildpacks:0.0.1-SNAPSHOT
.The repository contains configuration for Podman, I have not tested this against Docker, but I expect the results to be the same.
The Podman configuration will only activate when the
podman
profile is active during the Maven lifecylces (-Ppodman
).Motivations
I am trying to create smaller container images for our Spring boot projects. The JLink option has a large impact on the result and as such would be a great way to improve the sizes. This issue however is blocking progress, as the application will not function this way.
The text was updated successfully, but these errors were encountered: