org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.web.context.support.XmlWebApplicationContext(at)2c39d2' is defined

Spring JIRA | Eric Sirianni | 8 years ago
  1. 0

    I am getting an error when trying to autowire the spring application context into a class. <code> Component Scope("prototype") public class ServerOperationFactory { Autowired private ApplicationContext applicationContext; ... } </code> <code> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.web.context.support.XmlWebApplicationContext(at)2c39d2' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:391) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:999) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredElement.inject(AutowiredAnnotationBeanPostProcessor.java:356) ... 63 more </code> Stepping through in the debugger, it looks like this is the code that is filling in the ObjectUtils.identityToString() as the bean name for my autowired field is below: <code> DefaultListableBeanFactory.java: protected Map findAutowireCandidates(String beanName, Class requiredType, DependencyDescriptor descriptor) { String[] candidateNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this, requiredType); Map result = new LinkedHashMap(candidateNames.length); for (Iterator it = this.resolvableDependencies.keySet().iterator(); it.hasNext();) { Class autowiringType = (Class) it.next(); if (autowiringType.isAssignableFrom(requiredType)) { Object autowiringValue = this.resolvableDependencies.get(autowiringType); if (requiredType.isInstance(autowiringValue)) { result.put(ObjectUtils.identityToString(autowiringValue), autowiringValue); break; } } } </code> That code fills in for the "determined" bean name in the AutowiredElement object. Later, when that bean name is actually looked up in the bean factory (via beanFactory.getBean()) the BeanFactory fails to find the bean by that name, yielding the exception pasted above. This looks like a bug to me. Is there anything obvious I'm missing here? Thanks

    Spring JIRA | 8 years ago | Eric Sirianni
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.web.context.support.XmlWebApplicationContext(at)2c39d2' is defined
  2. 0

    I am getting an error when trying to autowire the spring application context into a class. <code> Component Scope("prototype") public class ServerOperationFactory { Autowired private ApplicationContext applicationContext; ... } </code> <code> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.web.context.support.XmlWebApplicationContext(at)2c39d2' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:391) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:999) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredElement.inject(AutowiredAnnotationBeanPostProcessor.java:356) ... 63 more </code> Stepping through in the debugger, it looks like this is the code that is filling in the ObjectUtils.identityToString() as the bean name for my autowired field is below: <code> DefaultListableBeanFactory.java: protected Map findAutowireCandidates(String beanName, Class requiredType, DependencyDescriptor descriptor) { String[] candidateNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this, requiredType); Map result = new LinkedHashMap(candidateNames.length); for (Iterator it = this.resolvableDependencies.keySet().iterator(); it.hasNext();) { Class autowiringType = (Class) it.next(); if (autowiringType.isAssignableFrom(requiredType)) { Object autowiringValue = this.resolvableDependencies.get(autowiringType); if (requiredType.isInstance(autowiringValue)) { result.put(ObjectUtils.identityToString(autowiringValue), autowiringValue); break; } } } </code> That code fills in for the "determined" bean name in the AutowiredElement object. Later, when that bean name is actually looked up in the bean factory (via beanFactory.getBean()) the BeanFactory fails to find the bean by that name, yielding the exception pasted above. This looks like a bug to me. Is there anything obvious I'm missing here? Thanks

    Spring JIRA | 8 years ago | Eric Sirianni
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.web.context.support.XmlWebApplicationContext(at)2c39d2' is defined
  3. 0

    how are annoted beans available in junit?

    Stack Overflow | 1 year ago | Albert Hendriks
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'edielbean' is defined at ....
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    grails 3.1.7 hibernate4 spring-security

    Stack Overflow | 6 months ago | Marco Di Scala
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '' is defined

    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 'org.springframework.web.context.support.XmlWebApplicationContext(at)2c39d2' is defined

      at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition()
    2. Spring Beans
      AutowiredAnnotationBeanPostProcessor$AutowiredElement.inject
      1. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:391)
      2. org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:999)
      3. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
      4. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
      5. org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredElement.inject(AutowiredAnnotationBeanPostProcessor.java:356)
      5 frames