Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.BeanDefinitionStoreException


    if (currentResources == null) {
      currentResources = new HashSet<EncodedResource>(4);
      this.resourcesCurrentlyBeingLoaded.set(currentResources);
    }
    if (!currentResources.add(encodedResource)) {
      throw new BeanDefinitionStoreException(
          "Detected recursive loading of " + encodedResource + " - check your import definitions!");
    }
    try {
      InputStream inputStream = encodedResource.getResource().getInputStream();
      try {
        InputSource inputSource = new InputSource(inputStream);
        if (encodedResource.getEncoding() != null) {
          inputSource.setEncoding(encodedResource.getEncoding());
        }
        return doLoadBeanDefinitions(inputSource, encodedResource.getResource());
      }
      finally {
        inputStream.close();
      }
    }
    catch (IOException ex) {
      throw new BeanDefinitionStoreException(
          "IOException parsing XML document from " + encodedResource.getResource(), ex);
    }
    finally {
      currentResources.remove(encodedResource);
      if (currentResources.isEmpty()) {
View Full Code Here


    catch (SAXException ex) {
      throw new XmlBeanDefinitionStoreException(resource.getDescription(),
          "XML document from " + resource + " is invalid", ex);
    }
    catch (ParserConfigurationException ex) {
      throw new BeanDefinitionStoreException(resource.getDescription(),
          "Parser configuration exception parsing XML from " + resource, ex);
    }
    catch (IOException ex) {
      throw new BeanDefinitionStoreException(resource.getDescription(),
          "IOException parsing XML document from " + resource, ex);
    }
    catch (Throwable ex) {
      throw new BeanDefinitionStoreException(resource.getDescription(),
          "Unexpected exception parsing XML document from " + resource, ex);
    }
  }
View Full Code Here

   * <p>Override this method if you would like to customize resolution
   * of the {@link #VALIDATION_AUTO} mode.
   */
  protected int detectValidationMode(Resource resource) {
    if (resource.isOpen()) {
      throw new BeanDefinitionStoreException(
          "Passed-in Resource [" + resource + "] contains an open stream: " +
          "cannot determine validation mode automatically. Either pass in a Resource " +
          "that is able to create fresh streams, or explicitly specify the validationMode " +
          "on your XmlBeanDefinitionReader instance.");
    }

    InputStream inputStream;
    try {
      inputStream = resource.getInputStream();
    }
    catch (IOException ex) {
      throw new BeanDefinitionStoreException(
          "Unable to determine validation mode for [" + resource + "]: cannot open InputStream. " +
          "Did you attempt to load directly from a SAX InputSource without specifying the " +
          "validationMode on your XmlBeanDefinitionReader instance?", ex);
    }

    try {
      return this.validationModeDetector.detectValidationMode(inputStream);
    }
    catch (IOException ex) {
      throw new BeanDefinitionStoreException("Unable to determine validation mode for [" +
          resource + "]: an error occurred whilst reading from the InputStream.", ex);
    }
  }
View Full Code Here

            "Group resource name [" + this.resourceLocation + "], factory key [" + factoryKey + "]");
      }
      reader.loadBeanDefinitions(configResources);
    }
    catch (IOException ex) {
      throw new BeanDefinitionStoreException(
          "Error accessing bean definition resource [" + this.resourceLocation + "]", ex);
    }
    catch (BeanDefinitionStoreException ex) {
      throw new FatalBeanException("Unable to load group definition: " +
          "group resource name [" + this.resourceLocation + "], factory key [" + factoryKey + "]", ex);
View Full Code Here

    }
    else if (value instanceof RuntimeBeanNameReference) {
      String refName = ((RuntimeBeanNameReference) value).getBeanName();
      refName = String.valueOf(evaluate(refName));
      if (!this.beanFactory.containsBean(refName)) {
        throw new BeanDefinitionStoreException(
            "Invalid bean name '" + refName + "' in bean reference for " + argName);
      }
      return refName;
    }
    else if (value instanceof BeanDefinitionHolder) {
View Full Code Here

                    "': cannot be resolved without an AbstractBeanFactory parent");
              }
            }
          }
          catch (NoSuchBeanDefinitionException ex) {
            throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanName,
                "Could not resolve parent bean definition '" + bd.getParentName() + "'", ex);
          }
          // Deep copy with overridden values.
          mbd = new RootBeanDefinition(pbd);
          mbd.overrideFrom(bd);
View Full Code Here

    }

    // Check validity of the usage of the args parameter. This can
    // only be used for prototypes constructed via a factory method.
    if (args != null && !mbd.isPrototype()) {
      throw new BeanDefinitionStoreException(
          "Can only specify arguments for the getBean method when referring to a prototype bean definition");
    }
  }
View Full Code Here

        is.close();
      }
      return registerBeanDefinitions(props, prefix, encodedResource.getResource().getDescription());
    }
    catch (IOException ex) {
      throw new BeanDefinitionStoreException("Could not parse properties from " + encodedResource.getResource(), ex);
    }
  }
View Full Code Here

   * @see #loadBeanDefinitions(org.springframework.core.io.Resource[])
   */
  public int loadBeanDefinitions(String location, Set<Resource> actualResources) throws BeanDefinitionStoreException {
    ResourceLoader resourceLoader = getResourceLoader();
    if (resourceLoader == null) {
      throw new BeanDefinitionStoreException(
          "Cannot import bean definitions from location [" + location + "]: no ResourceLoader available");
    }

    if (resourceLoader instanceof ResourcePatternResolver) {
      // Resource pattern matching available.
      try {
        Resource[] resources = ((ResourcePatternResolver) resourceLoader).getResources(location);
        int loadCount = loadBeanDefinitions(resources);
        if (actualResources != null) {
          for (Resource resource : resources) {
            actualResources.add(resource);
          }
        }
        if (logger.isDebugEnabled()) {
          logger.debug("Loaded " + loadCount + " bean definitions from location pattern [" + location + "]");
        }
        return loadCount;
      }
      catch (IOException ex) {
        throw new BeanDefinitionStoreException(
            "Could not resolve bean definition resource pattern [" + location + "]", ex);
      }
    }
    else {
      // Can only load single resources by absolute URL.
View Full Code Here

     
      // It's a static method if the target is null.
      return factoryMethod.invoke(factoryBean, args);
    }
    catch (IllegalArgumentException ex) {
      throw new BeanDefinitionStoreException(
          "Illegal arguments to factory method [" + factoryMethod + "]; " +
          "args: " + StringUtils.arrayToCommaDelimitedString(args));
    }
    catch (IllegalAccessException ex) {
      throw new BeanDefinitionStoreException(
          "Cannot access factory method [" + factoryMethod + "]; is it public?");
    }
    catch (InvocationTargetException ex) {
      throw new BeanDefinitionStoreException(
          "Factory method [" + factoryMethod + "] threw exception", ex.getTargetException());
    }
  }
View Full Code Here

TOP

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

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.