You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading from 4.1.x to 4.2.3 we are encountering problems regarding the processing of the @EventListener annotations.
Our Spring configurations (XML) contain a whole lot of beans defined for lazy init. These bean definitions are some times pre-configurations used by other projects (and could be overriden or replaced) and sometimes stage dependent beans, where the matching implementation is selected by aliases and/or <beans profile=".."> (and a more powerful self implemented equivalent) mechanism. Within the default configuration files, it is not possible to wrap the beans with <beans profile="..."> tags. We just do not know how the environments of our customers look like. Therefor the beans need to be directly defined with the lazy flag.
With 4.2.3 the org.springframework.context.event.EventListenerMethodProcessor introspects all beans defined, including the lazy defined ones. This loads the class (which up to 4.1.x did not happen!), causing NoClassDefFoundErrors if the class could not be loaded completely. I attached a minimal example, which instantiates the org.springframework.scheduling.commonj.TimerManagerTaskScheduler refering to the commonj.timers.TimerListener, which is not available outside the application server. This breaks spring context bootstrap in unit tests as well as when running in local tomcat, etc.
Is it possible to exclude lazy beans from processing?
Hmm, we indeed allow lazy beans to have unloadable classes. Our event listener detection algorithm should leniently accept that they are not loadable. I'll see what we can do there.
Fabian Schlier opened SPR-13712 and commented
After upgrading from 4.1.x to 4.2.3 we are encountering problems regarding the processing of the
@EventListener
annotations.Our Spring configurations (XML) contain a whole lot of beans defined for lazy init. These bean definitions are some times pre-configurations used by other projects (and could be overriden or replaced) and sometimes stage dependent beans, where the matching implementation is selected by aliases and/or
<beans profile="..">
(and a more powerful self implemented equivalent) mechanism. Within the default configuration files, it is not possible to wrap the beans with<beans profile="...">
tags. We just do not know how the environments of our customers look like. Therefor the beans need to be directly defined with the lazy flag.With 4.2.3 the
org.springframework.context.event.EventListenerMethodProcessor
introspects all beans defined, including the lazy defined ones. This loads the class (which up to 4.1.x did not happen!), causingNoClassDefFoundError
s if the class could not be loaded completely. I attached a minimal example, which instantiates theorg.springframework.scheduling.commonj.TimerManagerTaskScheduler
refering to thecommonj.timers.TimerListener
, which is not available outside the application server. This breaks spring context bootstrap in unit tests as well as when running in local tomcat, etc.Is it possible to exclude lazy beans from processing?
Affects: 4.2.3
Attachments:
Issue Links:
The text was updated successfully, but these errors were encountered: