Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.BeanCreationException


   * @return the bean instance as FactoryBean
   * @throws BeansException if the given bean cannot be exposed as a FactoryBean
   */
  protected FactoryBean getFactoryBean(String beanName, Object beanInstance) throws BeansException {
    if (!(beanInstance instanceof FactoryBean)) {
      throw new BeanCreationException(beanName,
          "Bean instance of type [" + beanInstance.getClass() + "] is not a FactoryBean");
    }
    return (FactoryBean) beanInstance;
  }
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

            }
          });
          bean = getObjectForBeanInstance(scopedInstance, name, beanName, mbd);
        }
        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

        try {
            props = PropertiesLoaderUtils.loadProperties(new ClassPathResource("beaninterfaces.properties"));
            log.debug("Properties: " +  props);
        }
        catch (IOException e1) {
            throw new BeanCreationException("Unable to load properties file beaninterfaces.properties", e1);
        }
        return props;
    }
View Full Code Here

        this.initParameters = (initParameters != null ? new HashMap<String, String>(initParameters) : new HashMap<String, String>());
       
        if (servletName == null) {
            if (moduleDefintion == null) {
                throw new BeanCreationException("No servlet name provide, and module definition is null");
            }
            servletName = moduleDefintion.getName();
        }
       
        servlet = ObjectUtils.cast(BeanUtils.instantiateClass(servletClass), Servlet.class);
View Full Code Here

        this.initParameters = (initParameters != null ? new HashMap<String, String>(initParameters) : new HashMap<String, String>());
       
        if (servletName == null) {
            if (moduleDefintion == null) {
                throw new BeanCreationException("No servlet name provide, and module definition is null");
            }
            servletName = moduleDefintion.getName();
        }
       
        servlet = ObjectUtils.cast(BeanUtils.instantiateClass(servletClass), Servlet.class);
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

            elementType = ClassUtils.forName(elementTypeName, this.beanFactory.getBeanClassLoader());
            array.resolvedElementType = elementType;
          }
          catch (Throwable ex) {
            // Improve the message by showing the context.
            throw new BeanCreationException(
                this.beanDefinition.getResourceDescription(), this.beanName,
                "Error resolving array type for " + argName, ex);
          }
        }
        else {
          elementType = Object.class;
        }
      }
      return resolveManagedArray(argName, (List<?>) value, elementType);
    }
    else if (value instanceof ManagedList) {
      // May need to resolve contained runtime references.
      return resolveManagedList(argName, (List<?>) value);
    }
    else if (value instanceof ManagedSet) {
      // May need to resolve contained runtime references.
      return resolveManagedSet(argName, (Set<?>) value);
    }
    else if (value instanceof ManagedMap) {
      // May need to resolve contained runtime references.
      return resolveManagedMap(argName, (Map<?, ?>) value);
    }
    else if (value instanceof ManagedProperties) {
      Properties original = (Properties) value;
      Properties copy = new Properties();
      for (Map.Entry propEntry : original.entrySet()) {
        Object propKey = propEntry.getKey();
        Object propValue = propEntry.getValue();
        if (propKey instanceof TypedStringValue) {
          propKey = evaluate((TypedStringValue) propKey);
        }
        if (propValue instanceof TypedStringValue) {
          propValue = evaluate((TypedStringValue) propValue);
        }
        copy.put(propKey, propValue);
      }
      return copy;
    }
    else if (value instanceof TypedStringValue) {
      // Convert value to target type here.
      TypedStringValue typedStringValue = (TypedStringValue) value;
      Object valueObject = evaluate(typedStringValue);
      try {
        Class<?> resolvedTargetType = resolveTargetType(typedStringValue);
        if (resolvedTargetType != null) {
          return this.typeConverter.convertIfNecessary(valueObject, resolvedTargetType);
        }
        else {
          return valueObject;
        }
      }
      catch (Throwable ex) {
        // Improve the message by showing the context.
        throw new BeanCreationException(
            this.beanDefinition.getResourceDescription(), this.beanName,
            "Error converting typed String value for " + argName, ex);
      }
    }
    else {
View Full Code Here

      else {
        return innerBean;
      }
    }
    catch (BeansException ex) {
      throw new BeanCreationException(
          this.beanDefinition.getResourceDescription(), this.beanName,
          "Cannot create inner bean '" + innerBeanName + "' " +
          (mbd != null && mbd.getBeanClassName() != null ? "of type [" + mbd.getBeanClassName() + "] " : "") +
          "while setting " + argName, 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.