Resolution : Apache commons configuration (XMLConfiguration) in a Spring bean
I was trying to inject apache commons configuration (XMLConfiguration) into a Spring bean and faced the error :
hint: specify index/type/name arguments for simple parameters to avoid type ambiguities
I was breaking my head for a while only to find later that my config XML is not even in the classpath. You can find the trace and the configuration below :
<bean id=”xmlConfig”>
<constructor-arg type=”java.net.URL” value=”classpath:alert-config.xml” />
<property name=”reloadingStrategy”>
<bean/>
</property>
</bean>
<bean id=”alertConfig”>
<property name=”xmlConfig” ref=”xmlConfig”></property>
</bean>
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'alertConfig' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'xmlConfig' while setting bean property 'xmlConfig'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xmlConfig' defined in class path resource [applicationContext.xml]: 1 constructor arguments specified but no matching constructor found in bean 'xmlConfig' (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
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:1317)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
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.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
at com.boa.alertxpert.config.AlertConfig.main(AlertConfig.java:21)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xmlConfig' defined in class path resource [applicationContext.xml]: 1 constructor arguments specified but no matching constructor found in bean 'xmlConfig' (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:175)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
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)
... 11 more




