aungmyo / impala

Automatically exported from code.google.com/p/impala
0 stars 0 forks source link

Autowiring of injected beans does not work. #292

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If attempting to autowire an imported bean of a particular type (e.g.
MessageService in the example sample), get:

Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name '/servlet2/test.to' defined in class path resource
[example-servlet2-context.xml]: Cannot resolve reference to bean
'autowiredClass' while setting bean property 'autowiredClass'; nested
exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'autowiredClass': Autowiring of methods failed;
nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire
method: public void
AutowiredClass.setMessageService(interfaces.MessageService); nested
exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique
bean of type [interfaces.MessageService] is defined: Unsatisfied dependency
of type [interface interfaces.MessageService]: expected at least 1 matching
bean
    at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveRef
erence(BeanDefinitionValueResolver.java:275)
    at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveVal
ueIfNecessary(BeanDefinitionValueResolver.java:104)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.app
lyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.pop
ulateBean(AbstractAutowireCapableBeanFactory.java:1010)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC
reateBean(AbstractAutowireCapableBeanFactory.java:472)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.r
un(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre
ateBean(AbstractAutowireCapableBeanFactory.java:380)
    at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Abstra
ctBeanFactory.java:264)
    at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingle
ton(DefaultSingletonBeanRegistry.java:222)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abstract
BeanFactory.java:261)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
anFactory.java:185)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
anFactory.java:164)
    at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractA
pplicationContext.java:880)
    at
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandle
r(AbstractUrlHandlerMapping.java:297)
    at
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandle
r(AbstractUrlHandlerMapping.java:276)
    at
org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detec
tHandlers(AbstractDetectingUrlHandlerMapping.java:82)
    at
org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initA
pplicationContext(AbstractDetectingUrlHandlerMapping.java:57)
    at
org.springframework.context.support.ApplicationObjectSupport.initApplicationCont
ext(ApplicationObjectSupport.java:119)
    at
org.springframework.web.context.support.WebApplicationObjectSupport.initApplicat
ionContext(WebApplicationObjectSupport.java:69)
    at
org.springframework.context.support.ApplicationObjectSupport.setApplicationConte
xt(ApplicationObjectSupport.java:73)
    at
org.springframework.context.support.ApplicationContextAwareProcessor.postProcess
BeforeInitialization(ApplicationContextAwareProcessor.java:70)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.app
lyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java
:350)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.ini
tializeBean(AbstractAutowireCapableBeanFactory.java:1331)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC
reateBean(AbstractAutowireCapableBeanFactory.java:473)
    ... 73 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'autowiredClass': Autowiring of methods failed;
nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire
method: public void
AutowiredClass.setMessageService(interfaces.MessageService); nested
exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique
bean of type [interfaces.MessageService] is defined: Unsatisfied dependency
of type [interface interfaces.MessageService]: expected at least 1 matching
bean
    at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcesso
r.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:256)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.pop
ulateBean(AbstractAutowireCapableBeanFactory.java:998)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC
reateBean(AbstractAutowireCapableBeanFactory.java:472)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.r
un(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre
ateBean(AbstractAutowireCapableBeanFactory.java:380)
    at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Abstra
ctBeanFactory.java:264)
    at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingle
ton(DefaultSingletonBeanRegistry.java:222)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abstract
BeanFactory.java:261)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
anFactory.java:185)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
anFactory.java:164)
    at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveRef
erence(BeanDefinitionValueResolver.java:269)
    ... 97 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could
not autowire method: public void
AutowiredClass.setMessageService(interfaces.MessageService); nested
exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique
bean of type [interfaces.MessageService] is defined: Unsatisfied dependency
of type [interface interfaces.MessageService]: expected at least 1 matching
bean
    at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcesso
r$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:543)
    at
org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(Inj
ectionMetadata.java:117)
    at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcesso
r.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:253)
    ... 108 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
No unique bean of type [interfaces.MessageService] is defined: Unsatisfied
dependency of type [interface interfaces.MessageService]: expected at least
1 matching bean
    at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDepe
ndency(DefaultListableBeanFactory.java:613)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPost

Original issue reported on code.google.com by philzoio...@googlemail.com on 5 Jan 2010 at 8:37

GoogleCodeExporter commented 9 years ago
r5206 contains files which can be used to reproduce this.

Original comment by philzoio...@googlemail.com on 5 Jan 2010 at 8:38

GoogleCodeExporter commented 9 years ago
Fixed with r5209

Original comment by philzoio...@googlemail.com on 8 Jan 2010 at 1:29