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 d551d509e5b..e24cac8d91b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import org.springframework.core.MethodIntrospector; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; /** * Register {@link EventListener} annotated method as individual {@link ApplicationListener} @@ -124,14 +125,23 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton, protected void processBean(final List factories, final String beanName, final Class targetType) { if (!this.nonAnnotatedClasses.contains(targetType)) { - Map annotatedMethods = MethodIntrospector.selectMethods(targetType, - new MethodIntrospector.MetadataLookup() { - @Override - public EventListener inspect(Method method) { - return AnnotationUtils.findAnnotation(method, EventListener.class); - } - }); - if (annotatedMethods.isEmpty()) { + Map annotatedMethods = null; + try { + annotatedMethods = MethodIntrospector.selectMethods(targetType, + new MethodIntrospector.MetadataLookup() { + @Override + public EventListener inspect(Method method) { + return AnnotationUtils.findAnnotation(method, EventListener.class); + } + }); + } + catch (Throwable ex) { + // An unresolvable type in a method signature, probably from a lazy bean - let's ignore it. + if (logger.isDebugEnabled()) { + logger.debug("Could not resolve methods for bean with name '" + beanName + "'", ex); + } + } + if (CollectionUtils.isEmpty(annotatedMethods)) { this.nonAnnotatedClasses.add(targetType); if (logger.isTraceEnabled()) { logger.trace("No @EventListener annotations found on bean class: " + targetType);