@Async メソッドを含む Bean を自動配線しようとしていますが、「自動配線された依存関係の注入に失敗しました」という例外で失敗しました
私のservlet.xmlには宣言が含まれています
<task:annotation-driven executor="executor" />
<task:executor id="executor" pool-size="7"/>
これが autowire に失敗する理由を教えてもらえますか?
--- 更新 --- エラーのスタック トレースは次のとおりです。
「cancelAppointment」は、Autowire が MailService Bean に対して行われる Bean id です。
2013-08-14 17:06:46,488|main|DEBUG|org.springframework.beans.factory.support.DisposableBeanAdapter|Invoking destroy() on bean with name 'org.springframework.scheduling.annotation.internalScheduledAnnotationProcessor'
2013-08-14 17:06:46,488|main|DEBUG|org.springframework.beans.factory.support.DisposableBeanAdapter|Invoking destroy() on bean with name 'executor'
2013-08-14 17:06:46,488|main|INFO|org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor|Shutting down ExecutorService
2013-08-14 17:06:46,492|main|ERROR|org.springframework.web.context.ContextLoader|Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cancelAppointment': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ge.appl.service.fs.manager.email.MailService com.ge.appl.service.fs.manager.cancel.consumer.CancelAppointmentImpl.mailService; nested exception is java.lang.IllegalArgumentException: Can not set com.ge.appl.service.fs.manager.email.MailService field com.ge.appl.service.fs.manager.cancel.consumer.CancelAppointmentImpl.mailService to $Proxy35
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
------ 更新 2 ------------ スタック トレースの詳細を次に示します。
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ge.appl.service.fs.manager.email.MailService com.ge.appl.service.fs.manager.cancel.consumer.CancelAppointmentImpl.mailService; nested exception is java.lang.IllegalArgumentException: Can not set com.ge.appl.service.fs.manager.email.MailService field com.ge.appl.service.fs.manager.cancel.consumer.CancelAppointmentImpl.mailService to $Proxy35
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 28 more
Caused by: java.lang.IllegalArgumentException: Can not set com.ge.appl.service.fs.manager.email.MailService field com.ge.appl.service.fs.manager.cancel.consumer.CancelAppointmentImpl.mailService to $Proxy35
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:657)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:498)
... 30 more
オートワイヤーが行われるクラスは次のようになります
@Component("cancelAppointment")
public class CancelAppointmentImpl extends AbstractCancelAppointment implements
CancelAppointment {
@Autowired
private MailService mailService;
@Override
public CancelAppointmentCriteria cancelAppointment(
final CancelAppointmentCriteria criteria) throws Exception {
// do something
try {
mailService.sendMail();
} catch (Exception e) {
// handle exception
}
} }