-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
request
-scoped bean with @Lazy
fails in native image (due to missing detection of CGLIB lazy resolution proxies)
#29584
Comments
Hey Josh, this is a variant of #29309 where we obviously fail to register the reflection hints for CGLIB proxy classes. As pointed out there by Ollie and Christoph, you can register those hints manually for the time being. We detect CGLIB proxy classes by top-level bean inspection in So for such scenarios, it would be good to understand why In your case, it seems that |
Alternatively, declaring the |
request
-scoped bean in a GraalVM / AOTrequest
-scoped bean with @Lazy
in a native image
An update after some analysis: It seems that we do indeed have a gap in our attempts to pre-resolve lazy resolution proxies for AOT where we currently detect and register JDK proxies but not CGLIB proxies in some scenarios. I'll make this consistent for 6.0.3, closing that specific gap and therefore widening the scenarios that we can discover upfront. This should also make the above scenario work as far as I can see. However, all the recommendations above stand nevertheless since it is generally a good idea to reduce unnecessary proxy requirements or make them exposed at the bean level at least. |
request
-scoped bean with @Lazy
in a native imagerequest
-scoped bean with @Lazy
fails in a native image (missing detection of CGLIB lazy resolution proxies)
request
-scoped bean with @Lazy
fails in a native image (missing detection of CGLIB lazy resolution proxies)request
-scoped bean with @Lazy
fails in a native image (due to missing detection of CGLIB lazy resolution proxies)
request
-scoped bean with @Lazy
fails in a native image (due to missing detection of CGLIB lazy resolution proxies)request
-scoped bean with @Lazy
fails in native image (due to missing detection of CGLIB lazy resolution proxies)
I've made the changes you suggested, and this works. Thanks! The only oddity is that it did work with the regular (non target-proxy) on the JRE. Each new request sees a new value for the |
Spring AOT (used to help Java native build) does not recognize proxies created by proxy. Use ObjectProvider instead. It is recommended anyway (even if no Java native build is used). See spring-projects/spring-framework#29584
Hi - I noticed what I think is a regression on the GraalVM/AOT handling of scoped beans
This issue (errantly put in the spring boot tracker and closed) has the details of a reproducible example.
spring-projects/spring-boot#33366
The text was updated successfully, but these errors were encountered: