Skip to content

EventListenerMethodProcessor resolves classes of lazy beans causing NoClassDefFoundError [SPR-13712] #17619

Closed
@spring-projects-issues

Description

@spring-projects-issues

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!), 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?


Affects: 4.2.3

Attachments:

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions