org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in file [/Users/timofeya/openSource/spring-aop-problem/target/classes/springbug/Client.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springbug.Client]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch

Spring JIRA | Timofey Asyrkin | 1 year ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    _Given_: - an abstract {{ParentClass}} which implements an {{Interface}} - a Bean(@Component) {{MyChildClass}} which extends {{ParentClass}} - a Bean(@Component) {{Client}} which uses {{MyChildClass}} injected via @Autowired constructor - an Aspect which advises all the methods in the project _When_: - a spring context starts _Then_: - the context initialization fails with the following exception {noformat} Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in file [/Users/timofeya/openSource/spring-aop-problem/target/classes/springbug/Client.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springbug.Client]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:275) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at Main.main(Main.java:8) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [springbug.Client]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:158) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:267) ... 19 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) ... 21 more {noformat} Investigation: - After adding logging into BeanUtils.java it became clear, that the proxy implements parent's interface {noformat} 2015-09-21 09:46:55 DEBUG BeanUtils:136 - argument [springbug.MyChildClass@5e4c8041] has class [class com.sun.proxy.$Proxy8], implements interfaces: [interface springbug.Interface, interface org.springframework.aop.SpringProxy, interface org.springframework.aop.framework.Advised] {noformat}

    Spring JIRA | 1 year ago | Timofey Asyrkin
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in file [/Users/timofeya/openSource/spring-aop-problem/target/classes/springbug/Client.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springbug.Client]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch
  2. 0

    _Given_: - an abstract {{ParentClass}} which implements an {{Interface}} - a Bean(@Component) {{MyChildClass}} which extends {{ParentClass}} - a Bean(@Component) {{Client}} which uses {{MyChildClass}} injected via @Autowired constructor - an Aspect which advises all the methods in the project _When_: - a spring context starts _Then_: - the context initialization fails with the following exception {noformat} Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in file [/Users/timofeya/openSource/spring-aop-problem/target/classes/springbug/Client.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springbug.Client]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:275) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at Main.main(Main.java:8) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [springbug.Client]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:158) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:267) ... 19 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) ... 21 more {noformat} Investigation: - After adding logging into BeanUtils.java it became clear, that the proxy implements parent's interface {noformat} 2015-09-21 09:46:55 DEBUG BeanUtils:136 - argument [springbug.MyChildClass@5e4c8041] has class [class com.sun.proxy.$Proxy8], implements interfaces: [interface springbug.Interface, interface org.springframework.aop.SpringProxy, interface org.springframework.aop.framework.Advised] {noformat}

    Spring JIRA | 1 year ago | Timofey Asyrkin
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in file [/Users/timofeya/openSource/spring-aop-problem/target/classes/springbug/Client.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springbug.Client]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch
  3. 0

    How to capture the authentication events?

    Stack Overflow | 4 years ago | cid
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Could not resolve matching constructor (hint: secify index/type/name arguments for simple parameters to avoid type ambiguities)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How to call Store Procedure within a package from Spring Integration

    Stack Overflow | 2 years ago | shoubhgh
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1da205c': Could not resolve matching constructor (hint: sp ecify index/type/name arguments for simple parameters to avoid type ambiguities)
  6. 0

    Error creating bean with name 'myServiceCustomerOffer' defined in ServletContext resource [/WEB-INF/beans.xml]

    Stack Overflow | 3 years ago | RaG
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myServiceCustomerOffer' defined in ServletContext resource [/WEB-INF/beans.xml]: 1 constructor arguments specified but no matching constructor found in bean 'myServiceCustomerOffer' (hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)

  1. haerick 2 times, last 8 months ago
  2. Nikolay Rybak 1 times, last 9 months ago
2 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 'client' defined in file [/Users/timofeya/openSource/spring-aop-problem/target/classes/springbug/Client.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springbug.Client]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch

    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor()
  2. Spring Beans
    ConstructorResolver.autowireConstructor
    1. org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:275)
    1 frame