org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customer4' defined in class path resource [com/springframework/jta/test.xml]: 2 constructor arguments specified but no matching constructor found in bean 'customer4' (hint: specify index arguments for simple parameters to avoid type ambiguities)

Spring JIRA | Alef Arendsen | 1 decade ago
  1. 0

    When using the following bean definition, the error message includes 'specify index arguments for simple types...', while index wouldn't help here. Maybe the hint should include specifying the type attribute as well. APP.CONTEXT ========================= <bean id="customer4" class="com.springframework.Customer"> <constructor-arg value="1" type="java.lang.Number"/> <constructor-arg value="2" type="java.lang.Integer"/> </bean> CONSTRUCTORS OF CUSTOMER CLASS ====================================== public Customer(Number n1, Number n2) { this.n1 = n1; this.n2 = n2; } public Customer(Integer i1, Integer i2) { this.n1 = i1; this.n2 = i2; } STACKTRACE =========== org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customer4' defined in class path resource [com/springframework/jta/test.xml]: 2 constructor arguments specified but no matching constructor found in bean 'customer4' (hint: specify index arguments for simple parameters to avoid type ambiguities) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:631) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:329)

    Spring JIRA | 1 decade ago | Alef Arendsen
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customer4' defined in class path resource [com/springframework/jta/test.xml]: 2 constructor arguments specified but no matching constructor found in bean 'customer4' (hint: specify index arguments for simple parameters to avoid type ambiguities)
  2. 0

    When using the following bean definition, the error message includes 'specify index arguments for simple types...', while index wouldn't help here. Maybe the hint should include specifying the type attribute as well. APP.CONTEXT ========================= <bean id="customer4" class="com.springframework.Customer"> <constructor-arg value="1" type="java.lang.Number"/> <constructor-arg value="2" type="java.lang.Integer"/> </bean> CONSTRUCTORS OF CUSTOMER CLASS ====================================== public Customer(Number n1, Number n2) { this.n1 = n1; this.n2 = n2; } public Customer(Integer i1, Integer i2) { this.n1 = i1; this.n2 = i2; } STACKTRACE =========== org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customer4' defined in class path resource [com/springframework/jta/test.xml]: 2 constructor arguments specified but no matching constructor found in bean 'customer4' (hint: specify index arguments for simple parameters to avoid type ambiguities) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:631) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:329)

    Spring JIRA | 1 decade ago | Alef Arendsen
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customer4' defined in class path resource [com/springframework/jta/test.xml]: 2 constructor arguments specified but no matching constructor found in bean 'customer4' (hint: specify index arguments for simple parameters to avoid type ambiguities)
  3. 0

    Could not autowire field + Injection of autowired dependencies failed

    Stack Overflow | 3 years ago | Mario
    org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.Ses sionFactory net.viralpatel.spring3.dao.ContactDAOImpl.sessionFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionExcept ion: No matching bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I am getting "org.springframework.beans.BeanInstantiationException" due to "unresolved compilation problems"

    Stack Overflow | 2 years ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'urlMapping' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registerProfileController' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [default.controller.RegisterProfileController]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: The import org.springframework cannot be resolved The import org.springframework cannot be resolved The import org.springframework cannot be resolved The import org.springframework cannot be resolved SimpleFormController cannot be resolved to a type Errors cannot be resolved to a type ModelAndView cannot be resolved to a type BindException cannot be resolved to a type ModelAndView cannot be resolved to a type ModelAndView cannot be resolved to a type The method getFormView() is undefined for the type RegisterProfileController ...
  6. 0

    Could not autowire field + Injection of autowired dependencies failed

    baba.io | 8 months ago
    org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.Ses sionFactory net.viralpatel.spring3.dao.ContactDAOImpl.sessionFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionExcept ion: No matching bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

  1. tfr 2 times, last 4 months ago
  2. linxiaolong 3 times, last 2 months ago
  3. qavid 24 times, last 4 months ago
7 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.beans.factory.BeanCreationException

    Error creating bean with name 'customer4' defined in class path resource [com/springframework/jta/test.xml]: 2 constructor arguments specified but no matching constructor found in bean 'customer4' (hint: specify index arguments for simple parameters to avoid type ambiguities)

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor()
  2. Spring Beans
    AbstractAutowireCapableBeanFactory.createBean
    1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:631)
    2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:329)
    2 frames