-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Reliably apply AspectJ weaving to @Component classes with LoadTimeWeaver setup on Tomcat #29609
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
Comments
Same issue here,
The most weird thing is that if the bean is declared in context with @bean annotation, it will be woven, if it's declared with @component and scanned with a base package, it will not be woven. It also affects version 6.0.3 |
I've analysed this issue and here's the report, including a workaround. Analysis happened against version 6.0.10. In
Workaround: The (*) This includes |
I have tried your workaroud and it works perfectly, thanks for your time. |
You're welcome. Maybe keep the issue open in order to keep it on the radar for a structural solution. |
@pdeneve Why is it that only when applying transformers in the fourth step can LTW (Load-Time Weaving) take effect? I look forward to your answer. Thank you. |
In essence, the transformation is applied for newly loaded classes from the moment AspectJ load time weaving is enabled. Because |
I think I understand what you mean, thank you. By the way, I have a question about the @EnableLoadTimeWeaving annotation. From its source code, it can be seen that this annotation registers a singleton LoadTimeWeaver.As it is well known, the creation of singleton beans is completed in the final stage of the Spring container refreshing, which is much later than the mentioned step 4. This means that ltw may not take effect for most beans. Does this imply that the @EnableLoadTimeWeaving annotation has some imperfections? |
Yes, I in that respect it has some imperfections. |
I've found a better workaround, one that does not involve adding a In The workaround involves making sure that The workaround works for I've updated the reference repository with the new workaround. |
Using the temporary class loader is indeed a better idea. I haven't come across the issue you mentioned where some auto-configured beans cannot be found. If you have already raised the issue, could you provide a link ? |
Yet another workaround involves using XML configuration. Unfortunately it's not possible to use this workaround in a Spring Boot application, because Spring Boot only allows for registering classes upfront, not XML configuration files. |
Affects: 6.0.2
We are trying to migrate from 5.3.19 to 6.0.2 and it seems that @service beans and @component beans are not woven anymore.
In our case, the result is that our @Transactionnal methods are no longer advised by the AnnotationTransactionAspect.
Looks like the issue was already present in older spring version.
I use the -javaagent:aspectjweaver.jar as a workaround but it is clearly not ideal for our project.
The text was updated successfully, but these errors were encountered: