Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.BeanCreationException


   */
  private Object resolveReference(Object argName, RuntimeBeanReference ref) {
    try {
      if (ref.isToParent()) {
        if (this.beanFactory.getParentBeanFactory() == null) {
          throw new BeanCreationException(
              this.beanDefinition.getResourceDescription(), this.beanName,
              "Can't resolve reference to bean '" + ref.getBeanName() +
              "' in parent factory: no parent factory available");
        }
        return this.beanFactory.getParentBeanFactory().getBean(ref.getBeanName());
      }
      else {
        Object bean = this.beanFactory.getBean(ref.getBeanName());
        this.beanFactory.registerDependentBean(ref.getBeanName(), this.beanName);
        return bean;
      }
    }
    catch (BeansException ex) {
      throw new BeanCreationException(
          this.beanDefinition.getResourceDescription(), this.beanName,
          "Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
    }
  }
View Full Code Here


        result.put(beanName, getBean(beanName));
      }
      catch (BeanCreationException ex) {
        Throwable rootCause = ex.getMostSpecificCause();
        if (rootCause instanceof BeanCurrentlyInCreationException) {
          BeanCreationException bce = (BeanCreationException) rootCause;
          if (isCurrentlyInCreation(bce.getBeanName())) {
            if (this.logger.isDebugEnabled()) {
              this.logger.debug("Ignoring match to currently created bean '" + beanName + "': " + ex.getMessage());
            }
            onSuppressedException(ex);
            // Ignore: indicates a circular reference when autowiring constructors.
View Full Code Here

            }
          });
          bean = getObjectForBeanInstance(scopedInstance, name, beanName);
        }
        catch (IllegalStateException ex) {
          throw new BeanCreationException(beanName,
              "Scope '" + scopeName + "' is not active for the current thread; " +
              "consider defining a scoped proxy for this bean if you intend to refer to it from a singleton",
              ex);
        }
      }
View Full Code Here

          registrar.registerCustomEditors(registry);
        }
        catch (BeanCreationException ex) {
          Throwable rootCause = ex.getMostSpecificCause();
          if (rootCause instanceof BeanCurrentlyInCreationException) {
            BeanCreationException bce = (BeanCreationException) rootCause;
            if (isCurrentlyInCreation(bce.getBeanName())) {
              if (logger.isDebugEnabled()) {
                logger.debug("PropertyEditorRegistrar [" + registrar.getClass().getName() +
                    "] failed because it tried to obtain currently created bean '" + ex.getBeanName() +
                    "': " + ex.getMessage());
              }
View Full Code Here

        }
        catch (FactoryBeanNotInitializedException ex) {
          throw new BeanCurrentlyInCreationException(beanName, ex.toString());
        }
        catch (Throwable ex) {
          throw new BeanCreationException(beanName, "FactoryBean threw exception on object creation", ex);
        }

        // Do not accept a null value for a FactoryBean that's not fully
        // initialized yet: Many FactoryBeans just return null then.
        if (object == null && isSingletonCurrentlyInCreation(beanName)) {
          throw new BeanCurrentlyInCreationException(
              beanName, "FactoryBean which is currently in creation returned null from getObject");
        }

        if (object != null && (mbd == null || !mbd.isSynthetic())) {
          try {
            object = postProcessObjectFromFactoryBean(object, beanName);
          }
          catch (Throwable ex) {
            throw new BeanCreationException(mbd.getResourceDescription(), beanName,
                "Post-processing of the FactoryBean's object failed", ex);
          }
        }

        return object;
View Full Code Here

          if (bean != null) {
            return bean;
          }
        }
        catch (Throwable ex) {
          throw new BeanCreationException(mbd.getResourceDescription(), beanName,
              "BeanPostProcessor before instantiation of bean failed", ex);
        }

        return doCreateBean(beanName, mbd, args);
      }
View Full Code Here

    catch (Throwable ex) {
      if (ex instanceof BeanCreationException && beanName.equals(((BeanCreationException) ex).getBeanName())) {
        throw (BeanCreationException) ex;
      }
      else {
        throw new BeanCreationException(mbd.getResourceDescription(), beanName, "Initialization of bean failed", ex);
      }
    }

    if (!this.allowRawInjectionDespiteWrapping && originalBean != bean &&
        mbd.isSingleton() && hasDependentBean(beanName)) {
View Full Code Here

      finally {
        // Finished partial creation of this bean.
        afterSingletonCreation(beanName);
      }
      if (!(instance instanceof FactoryBean)) {
        throw new BeanCreationException(beanName,
            "Bean instance of type [" + instance.getClass() + "] is not a FactoryBean");
      }
      if (bw != null) {
        this.factoryBeanInstanceCache.put(beanName, bw);
      }
View Full Code Here

    finally {
      // Finished partial creation of this bean.
      afterPrototypeCreation(beanName);
    }
    if (!(instance instanceof FactoryBean)) {
      throw new BeanCreationException(beanName,
          "Bean instance of type [" + instance.getClass() + "] is not a FactoryBean");
    }
    return (FactoryBean) instance;
  }
View Full Code Here

      BeanWrapper bw = new BeanWrapperImpl(beanInstance);
      initBeanWrapper(bw);
      return bw;
    }
    catch (Throwable ex) {
      throw new BeanCreationException(mbd.getResourceDescription(), beanName, "Instantiation of bean failed", ex);
    }
  }
View Full Code Here

TOP

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

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.