diff --git a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java index 3c73fa4dcd..15779599cd 100644 --- a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java @@ -75,7 +75,16 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton, String[] allBeanNames = this.applicationContext.getBeanNamesForType(Object.class); for (String beanName : allBeanNames) { if (!ScopedProxyUtils.isScopedTarget(beanName)) { - Class type = AutoProxyUtils.determineTargetClass(this.applicationContext.getBeanFactory(), beanName); + Class type = null; + try { + type = AutoProxyUtils.determineTargetClass(this.applicationContext.getBeanFactory(), beanName); + } + catch (Throwable ex) { + // An unresolvable bean type, probably from a lazy bean - let's ignore it. + if (logger.isDebugEnabled()) { + logger.debug("Could not resolve target class for bean with name '" + beanName + "'", ex); + } + } if (type != null) { if (ScopedObject.class.isAssignableFrom(type)) { try { @@ -107,8 +116,7 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton, * {@link EventListener} annotated methods. */ protected List getEventListenerFactories() { - Map beans = - this.applicationContext.getBeansOfType(EventListenerFactory.class); + Map beans = this.applicationContext.getBeansOfType(EventListenerFactory.class); List allFactories = new ArrayList(beans.values()); AnnotationAwareOrderComparator.sort(allFactories); return allFactories;