Error creating bean Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)



I have a java application (maven project) that has a parent root. the application have a dependencies in other projects under root and when this application initialize the context an error is thrown:



[LogFactory from sun.misc.Launcher$AppClassLoader@131165903] Created object org.apache.logging.log4j.jcl.LogFactoryImpl@173728231 to manage classloader sun.misc.Launcher$AppClassLoader@131165903
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'retriableOperationExecutor' defined in file [C:\evergreen\lt-pcqc\app\Backend\Common\lab-common\target\classes\Spring\qcext-pclab-retriable-operation-executor-context.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1051)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:955)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at com.hp.alm.lab.common.spring.SpringContextLoader.loadContext(SpringContextLoader.java:44)


an xml file is beeing loaded and from some reason don't find its relevant constructor although it is located in the same jar that holds the xml file.


other project that holds a dependency to the same project is running on a jetty server without any exceptions. here is the xml file:



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/1jdM0fG">

<bean id="retriableOperationExecutor" class="com.hp.alm.lab.common.utils.RetriableOperationExecutor" scope="singleton">
<constructor-arg name="Default_Count" index="0" type="int" value="${default_count:5}"/>
<constructor-arg name="Initial_Sleep_Millis" index="1" type="int" value="${initial_sleep_millis:2000}"/>
<constructor-arg name="Max_Sleep_Time" index="2" type="int" value="${max_sleep_time:30000}"/>
</bean>
</beans>


and the relevant constructor is:



public class RetriableOperationExecutor {


private static int DEFAULT_COUNT;
private static int INITIAL_SLEEP_MILLIS;
private static int MAX_SLEEP_TIME;

public RetriableOperationExecutor(int Default_Count,int Initial_Sleep_Millis,int Max_Sleep_Time) {
DEFAULT_COUNT=Default_Count;
INITIAL_SLEEP_MILLIS=Initial_Sleep_Millis;
MAX_SLEEP_TIME=Max_Sleep_Time;
}

public RetriableOperationExecutor() {}


I did try to add the index, name, in the constructor-arg but without any luck.


any idea?


No comments:

Post a Comment