IllegalAccessError for some auto-configured beans when enabling AspectJ load time weaving #31300
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: feedback-provided
Feedback has been provided
status: waiting-for-triage
An issue we've not yet triaged or decided on
Created this issue as suggested here.
To enable AspectJ load time weaving in a Spring application, one would use the
@EnableLoadTimeWeaving
annotation as outlined in the Spring reference documention. Due to issue 29609 this is not working and a workaround proposed involves registeringAspectJWeavingEnabler
andDefaultContextLoadTimeWeaver
upfront when instantiating the application context. For a spring boot application, this looks as follows:With
MyLoadTimeWeaver
extendingDefaultContextLoadTimeWeaver
and annotated with@Component("loadTimeWeaver")
because the name of theLoadTimeWeaver
bean "loadTimeWeaver
" is expected by the framework.When running the application, some auto-configured beans cannot be accessed anymore. E.g. for the
spring.boot.ltw
module in this repository, the following stacktrace is produced:To reproduce yourself:
spring_boot_issue
mvn compile -pl spring.boot.ltw
JAVA_HOME
points to a Java 21 JDKmvn dependency:properties exec:exec -pl spring.boot.ltw
It is possible to workaround this issue by defining manually the beans for which an
IllegalAccessError
occurs. E.g. for the sample project, uncomment the@Bean
annotation for theJdbcConnectionDetails
bean inConfig.java
and it will work.The text was updated successfully, but these errors were encountered: