I have several methods annotated with @scheduled and the majority of them run just fine but one of them in particular is not invoked via a proxy, it is invoked directly. The method is on a class annotated with @Service and @Transactional and that class has an appropriate interface with the method signature on it; i.e. I'm using JDK dynamic proxies.
The @scheduled annotation is on the implementation of the method. There is nothing unique about this method compared to my other @scheduled methods as far as I can tell.
That exact same method, when invoked via a web endpoint works as expected (via proxy and a transaction is available).
I've included some example code in the linked stack overflow post; let me know if I should copy some of that here.
I was able to try it against both 4.2.4 as well as the 4.3.0 snapshot and I'm still encountering the same issue.
Is there anything short of a fully functional test case that I can provide? I'm worried that will be difficult for me to create because I don't know what is unique about this one particular scheduled method (and it is a small part of a very large application).
Thanks for your assistance; it is very much appreciated.
I have encountered this issue today with 4.2.6. I believe that the cause behind this issue is that the bean with @Scheduled method is autowired somewhere without being wrapped in a proxy (or before it is wrapped by a proxy?). Because of that the bean itself and not the proxy is picked up by ScheduledAnnotationBeanPostProcessor.
It is possible to work around this issue by moving @Scheduled methods into a separate singleton-scoped bean.
This might be caused by an effect similar to #20469 where early injection (possibly self-injection) causes a shortcut where the proxy isn't always present, so ScheduledAnnotationBeanPostProcessor doesn't reliably see it.
A reproducible test would be great here. It's still unclear what the exact circumstances are.