Hi,
I'm using Spring 3.0.5 and @Autowired doesnt work in my Java @Configuration when i'm instantiating a @Bean that implements <b>FactoryBean,
BeanNameAware, InitializingBean, DisposableBean, BeanPostProcessor,
PriorityOrdered</b>.
The internal class comments state the following:
// INTERNAL DOCS ON WHY WE IMPLEMENT ALL THESE INTERFACES:
// In order to make sure that MSNetAdminManager is created before all beans
// of type BeanPostProcessor
// we implement PriorityOrdered to make sure our BeanPostProcessor method
// are applied to any other
// BeanPostProcessors who do not implement PriorityOrdered.
It seems like the authors of this class went to great length in customizing how this bean is created and it is obviously throwing off Java Config code, interestingly the same works in traditional XML config...
Any spring experts would have some hints on how to get out of this mess?
I get the following stacktrace (partial):
Code:at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:689) ~[org.springframework.context.jar:3.0.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410) ~[org.springframework.context.jar:3.0.5.RELEASE] at msjava.base.application.SpringMain.run(SpringMain.java:112) [msjava_base.jar.0:2012.04.29] at msjava.base.application.SpringMain.run(SpringMain.java:93) [msjava_base.jar.0:2012.04.29] at msjava.base.application.SpringMain.main(SpringMain.java:135) [msjava_base.jar.0:2012.04.29] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authorizationVoter' defined in class path resource [mssb/cads/tmr/common/config/TmrNetAdminCommonConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: directory should not be null. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) ~[org.springframework.beans.jar:3.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[org.springframework.beans.jar:3.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[org.springframework.beans.jar:3.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) ~[org.springframework.beans.jar:3.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[org.springframework.beans.jar:3.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) ~[org.springframework.beans.jar:3.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) ~[org.springframework.beans.jar:3.0.5.RELEASE] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) ~[org.springframework.beans.jar:3.0.5.RELEASE] ... 14 common frames omitted Caused by: java.lang.IllegalStateException: directory should not be null. at msjava.integrations.spring.authorization.MSLdapAccessDecisionVoter.afterPropertiesSet(MSLdapAccessDecisionVoter.java:320) ~[msjava_integrations.jar.0:2012.04.29] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) ~[org.springframework.beans.jar:3.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ~[org.springframework.beans.jar:3.0.5.RELEASE] ... 21 common frames omitted Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminManager' defined in class path resource [appContext/admin-context.xml]: Cannot resolve reference to bean 'authorizationVoter' while setting bean property 'accessDecisionVoter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authorizationVoter' defined in class path resource [mssb/cads/tmr/common/config/TmrNetAdminCommonConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: directory should not be null. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) 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:194) at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:689) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410) at msjava.base.application.SpringMain.run(SpringMain.java:112) at msjava.base.application.SpringMain.run(SpringMain.java:93) at msjava.base.application.SpringMain.main(SpringMain.java:135) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authorizationVoter' defined in class path resource [mssb/cads/tmr/common/config/TmrNetAdminCommonConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: directory should not be null. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 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.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) ... 14 more Caused by: java.lang.IllegalStateException: directory should not be null. at msjava.integrations.spring.authorization.MSLdapAccessDecisionVoter.afterPropertiesSet(MSLdapAccessDecisionVoter.java:320) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 21 more


Reply With Quote
