org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exampleService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: de.codecentric.batch.item.SubExampleService de.codecentric.batch.item.ExampleService.subExampleService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined

Spring JIRA | Max Hartmann | 2 years ago
  1. 0

    When I use a GenericContextFactory with a parent context and in the childContext there is a quite simple @Qualifier constellation the startup of the context fails. If I use @Autowired without a qualifier all is fine. Sample: AnnotationConfigApplicationContext parentContext = new AnnotationConfigApplicationContext(); parentContext.register(String.class); parentContext.refresh(); GenericApplicationContextFactory factory = new GenericApplicationContextFactory(ExampleService.class, SubExampleService.class); factory.setApplicationContext(parentContext); factory.createApplicationContext(); public class ExampleService { @Autowired @Qualifier("subExampleService") SubExampleService subExampleService; public String echo(String echo) { return subExampleService.echo(echo); } } exception: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exampleService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: de.codecentric.batch.item.SubExampleService de.codecentric.batch.item.ExampleService.subExampleService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1147) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:633) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.batch.core.configuration.support.GenericApplicationContextFactory$ResourceAnnotationApplicationContext.<init>(GenericApplicationContextFactory.java:209) at org.springframework.batch.core.configuration.support.GenericApplicationContextFactory.createApplicationContext(GenericApplicationContextFactory.java:68) at org.springframework.batch.core.configuration.support.AbstractApplicationContextFactory.createApplicationContext(AbstractApplicationContextFactory.java:170) at de.codecentric.batch.Application.main(Application.java:30) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: de.codecentric.batch.item.SubExampleService de.codecentric.batch.item.ExampleService.subExampleService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286) ... 14 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:575) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1111) at org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:572) at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.checkQualifier(QualifierAnnotationAutowireCandidateResolver.java:249) at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.checkQualifiers(QualifierAnnotationAutowireCandidateResolver.java:183) at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.isAutowireCandidate(QualifierAnnotationAutowireCandidateResolver.java:157) at org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:564) at org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:531) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:916) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:860) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:775) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489) ... 16 more thx

    Spring JIRA | 2 years ago | Max Hartmann
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exampleService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: de.codecentric.batch.item.SubExampleService de.codecentric.batch.item.ExampleService.subExampleService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined
  2. 0

    When I use a GenericContextFactory with a parent context and in the childContext there is a quite simple @Qualifier constellation the startup of the context fails. If I use @Autowired without a qualifier all is fine. Sample: AnnotationConfigApplicationContext parentContext = new AnnotationConfigApplicationContext(); parentContext.register(String.class); parentContext.refresh(); GenericApplicationContextFactory factory = new GenericApplicationContextFactory(ExampleService.class, SubExampleService.class); factory.setApplicationContext(parentContext); factory.createApplicationContext(); public class ExampleService { @Autowired @Qualifier("subExampleService") SubExampleService subExampleService; public String echo(String echo) { return subExampleService.echo(echo); } } exception: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exampleService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: de.codecentric.batch.item.SubExampleService de.codecentric.batch.item.ExampleService.subExampleService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1147) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:633) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.batch.core.configuration.support.GenericApplicationContextFactory$ResourceAnnotationApplicationContext.<init>(GenericApplicationContextFactory.java:209) at org.springframework.batch.core.configuration.support.GenericApplicationContextFactory.createApplicationContext(GenericApplicationContextFactory.java:68) at org.springframework.batch.core.configuration.support.AbstractApplicationContextFactory.createApplicationContext(AbstractApplicationContextFactory.java:170) at de.codecentric.batch.Application.main(Application.java:30) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: de.codecentric.batch.item.SubExampleService de.codecentric.batch.item.ExampleService.subExampleService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286) ... 14 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:575) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1111) at org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:572) at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.checkQualifier(QualifierAnnotationAutowireCandidateResolver.java:249) at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.checkQualifiers(QualifierAnnotationAutowireCandidateResolver.java:183) at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.isAutowireCandidate(QualifierAnnotationAutowireCandidateResolver.java:157) at org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:564) at org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:531) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:916) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:860) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:775) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489) ... 16 more thx

    Spring JIRA | 2 years ago | Max Hartmann
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exampleService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: de.codecentric.batch.item.SubExampleService de.codecentric.batch.item.ExampleService.subExampleService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'subExampleService' is defined
  3. 0

    技術検証2日目 | 男はロマン

    otokoroman.com | 7 months ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hessian Webservice with REST, Java Spring

    Stack Overflow | 4 years ago | Cid Immacula
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'photoService' bean method public java.lang.Object mppiwebservices.photoservices.impl.photo.PhotoServicesImpl.savePhoto(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,mppiwebservices.photoservices.pojo.Photo,org.springframework.validation.BindingResult,org.springframework.web.bind.support.SessionStatus) to {[/{user}/{folder_name}/savephoto/],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'photoServicesImpl' bean method public java.lang.Object mppiwebservices.photoservices.impl.photo.PhotoServicesImpl.savePhoto(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,mppiwebservices.photoservices.pojo.Photo,org.springframework.validation.BindingResult,org.springframework.web.bind.support.SessionStatus) mapped.
  6. 0

    Problems getting facebook client to work

    GitHub | 2 years ago | pashtika
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userApprovalHandler' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'tokenServices' of bean class [org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler]: Bean property 'tokenServices' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

  1. rlovtangen 2 times, last 2 weeks ago
  2. tvrmsmith 6 times, last 2 weeks ago
  3. kjhdofjosvs 1 times, last 3 weeks ago
  4. Andreas Häber 2 times, last 3 weeks ago
  5. Luka 14 times, last 2 months ago
21 more registered users
74 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.NoSuchBeanDefinitionException

    No bean named 'subExampleService' is defined

    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition()
  2. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:575)
    2. org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1111)
    3. org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:572)
    4. org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.checkQualifier(QualifierAnnotationAutowireCandidateResolver.java:249)
    5. org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.checkQualifiers(QualifierAnnotationAutowireCandidateResolver.java:183)
    6. org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.isAutowireCandidate(QualifierAnnotationAutowireCandidateResolver.java:157)
    7. org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:564)
    8. org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:531)
    9. org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:916)
    10. org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:860)
    11. org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:775)
    12. org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
    13. org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    14. org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
    15. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1147)
    16. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    17. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    18. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    19. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    20. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    21. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    22. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:633)
    22 frames
  3. Spring Context
    AbstractApplicationContext.refresh
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    2 frames
  4. Spring Batch Core
    AbstractApplicationContextFactory.createApplicationContext
    1. org.springframework.batch.core.configuration.support.GenericApplicationContextFactory$ResourceAnnotationApplicationContext.<init>(GenericApplicationContextFactory.java:209)
    2. org.springframework.batch.core.configuration.support.GenericApplicationContextFactory.createApplicationContext(GenericApplicationContextFactory.java:68)
    3. org.springframework.batch.core.configuration.support.AbstractApplicationContextFactory.createApplicationContext(AbstractApplicationContextFactory.java:170)
    3 frames
  5. de.codecentric.batch
    Application.main
    1. de.codecentric.batch.Application.main(Application.java:30)
    1 frame