Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.BeanCreationException


    InjectionMetadata metadata = findAutowiringMetadata(clazz);
    try {
      metadata.inject(bean, null, null);
    }
    catch (Throwable ex) {
      throw new BeanCreationException("Injection of autowired dependencies failed for class [" + clazz + "]", ex);
    }
  }
View Full Code Here


          ReflectionUtils.makeAccessible(field);
          field.set(bean, value);
        }
      }
      catch (Throwable ex) {
        throw new BeanCreationException("Could not autowire field: " + field, ex);
      }
    }
View Full Code Here

      }
      catch (InvocationTargetException ex) {
        throw ex.getTargetException();
      }
      catch (Throwable ex) {
        throw new BeanCreationException("Could not autowire method: " + method, ex);
      }
    }
View Full Code Here

    InjectionMetadata metadata = findResourceMetadata(bean.getClass());
    try {
      metadata.inject(bean, beanName, pvs);
    }
    catch (Throwable ex) {
      throw new BeanCreationException(beanName, "Injection of resource dependencies failed", ex);
    }
    return pvs;
  }
View Full Code Here

    InjectionMetadata metadata = findPersistenceMetadata(bean.getClass());
    try {
      metadata.inject(bean, beanName, pvs);
    }
    catch (Throwable ex) {
      throw new BeanCreationException(beanName, "Injection of persistence dependencies failed", ex);
    }
    return pvs;
  }
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);
    }

    Object beanInstance = doCreateBean(beanName, mbd, args);
    if (logger.isDebugEnabled()) {
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 (earlySingletonExposure) {
      Object earlySingletonReference = getSingleton(beanName, false);
      if (earlySingletonReference != null) {
        if (exposedObject == bean) {
          exposedObject = earlySingletonReference;
        }
        else if (!this.allowRawInjectionDespiteWrapping && hasDependentBean(beanName)) {
          String[] dependentBeans = getDependentBeans(beanName);
          Set<String> actualDependentBeans = new LinkedHashSet<String>(dependentBeans.length);
          for (String dependentBean : dependentBeans) {
            if (!removeSingletonIfCreatedForTypeCheckOnly(dependentBean)) {
              actualDependentBeans.add(dependentBean);
            }
          }
          if (!actualDependentBeans.isEmpty()) {
            throw new BeanCurrentlyInCreationException(beanName,
                "Bean with name '" + beanName + "' has been injected into other beans [" +
                StringUtils.collectionToCommaDelimitedString(actualDependentBeans) +
                "] in its raw version as part of a circular reference, but has eventually been " +
                "wrapped. This means that said other beans do not use the final version of the " +
                "bean. This is often the result of over-eager type matching - consider using " +
                "'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.");
          }
        }
      }
    }

    // Register bean as disposable.
    try {
      registerDisposableBeanIfNecessary(beanName, bean, mbd);
    }
    catch (BeanDefinitionValidationException ex) {
      throw new BeanCreationException(mbd.getResourceDescription(), beanName, "Invalid destruction signature", ex);
    }

    return exposedObject;
  }
View Full Code Here

        result.put(beanName, getBean(beanName, type));
      }
      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);
View Full Code Here

          bdp.postProcessMergedBeanDefinition(mbd, beanType, beanName);
        }
      }
    }
    catch (Exception ex) {
      throw new BeanCreationException(mbd.getResourceDescription(), beanName,
          "Post-processing failed of bean type [" + beanType + "] failed", ex);
    }
  }
View Full Code Here

  protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd, Object[] args) {
    // Make sure bean class is actually resolved at this point.
    Class beanClass = resolveBeanClass(mbd, beanName);

    if (beanClass != null && !Modifier.isPublic(beanClass.getModifiers()) && !mbd.isNonPublicAccessAllowed()) {
      throw new BeanCreationException(mbd.getResourceDescription(), beanName,
          "Bean class isn't public, and non-public access not allowed: " + beanClass.getName());
    }

    if (mbd.getFactoryMethodName() != null)  {
      return instantiateUsingFactoryMethod(beanName, mbd, args);
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.