Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.NoSuchBeanDefinitionException


  public Object getBean(String name) throws BeansException {
    String beanName = BeanFactoryUtils.transformedBeanName(name);
    Object bean = this.beans.get(beanName);

    if (bean == null) {
      throw new NoSuchBeanDefinitionException(beanName,
          "Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]");
    }

    // Don't let calling code try to dereference the
    // bean factory if the bean isn't a factory
View Full Code Here


    String[] beanNames = getBeanNamesForType(requiredType);
    if (beanNames.length == 1) {
      return getBean(beanNames[0], requiredType);
    }
    else {
      throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found " + beanNames.length);
    }
  }
View Full Code Here

  public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
    String beanName = BeanFactoryUtils.transformedBeanName(name);

    Object bean = this.beans.get(beanName);
    if (bean == null) {
      throw new NoSuchBeanDefinitionException(beanName,
          "Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]");
    }

    if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
      // If it's a FactoryBean, we want to look at what it creates, not the factory class.
View Full Code Here

    }
    if (this.alwaysUseJndiLookup) {
      return this.jndiFactory.getBean(element.name, element.lookupType);
    }
    if (this.resourceFactory == null) {
      throw new NoSuchBeanDefinitionException(element.lookupType,
          "No resource factory configured - specify the 'resourceFactory' property");
    }
    return autowireResource(this.resourceFactory, element, requestingBeanName);
  }
View Full Code Here

            ((ConfigurableBeanFactory) beanFactory).registerDependentBean(this.beanName, requestingBeanName);
          }
          return bean;
        }
        else if (this.isDefaultName && !StringUtils.hasLength(this.mappedName)) {
          throw new NoSuchBeanDefinitionException(this.beanName,
              "Cannot resolve 'beanName' in local BeanFactory. Consider specifying a general 'name' value instead.");
        }
      }
      // JNDI name lookup - may still go to a local BeanFactory.
      return getResource(this, requestingBeanName);
View Full Code Here

        ((ConfigurableBeanFactory) this.beanFactory).registerDependentBean(unitName, requestingBeanName);
      }
      return emf;
    }
    else {
      throw new NoSuchBeanDefinitionException(
          EntityManagerFactory.class, "expected single bean but found " + beanNames.length);
    }
  }
View Full Code Here

    }
    else if (beanNames.length == 0 && getParentBeanFactory() != null) {
      return getParentBeanFactory().getBean(requiredType);
    }
    else {
      throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found " +
          beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames));
    }
  }
View Full Code Here

    BeanDefinition bd = this.beanDefinitionMap.get(beanName);
    if (bd == null) {
      if (this.logger.isTraceEnabled()) {
        this.logger.trace("No bean named '" + beanName + "' found in " + this);
      }
      throw new NoSuchBeanDefinitionException(beanName);
    }
    return bd;
  }
View Full Code Here

      BeanDefinition bd = this.beanDefinitionMap.remove(beanName);
      if (bd == null) {
        if (this.logger.isTraceEnabled()) {
          this.logger.trace("No bean named '" + beanName + "' found in " + this);
        }
        throw new NoSuchBeanDefinitionException(beanName);
      }
      this.beanDefinitionNames.remove(beanName);
      this.frozenBeanDefinitionNames = null;

      resetBeanDefinition(beanName);
View Full Code Here

        return null;
      }
      if (matchingBeans.size() > 1) {
        String primaryBeanName = determinePrimaryCandidate(matchingBeans, descriptor);
        if (primaryBeanName == null) {
          throw new NoSuchBeanDefinitionException(type, "expected single matching bean but found " +
              matchingBeans.size() + ": " + matchingBeans.keySet());
        }
        if (autowiredBeanNames != null) {
          autowiredBeanNames.add(primaryBeanName);
        }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.NoSuchBeanDefinitionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.