Package org.springframework.beans

Examples of org.springframework.beans.BeanInstantiationException


    public void setCamelContext(CamelContext camelContext) {
        this.camelContext = camelContext;
        postProcessor = new CamelPostProcessorHelper(camelContext) {
            @Override
            protected RuntimeException createProxyInstantiationRuntimeException(Class<?> type, Endpoint endpoint, Exception e) {
                return new BeanInstantiationException(type, "Could not instantiate proxy of type " + type.getName() + " on endpoint " + endpoint, e);
            }

            protected boolean isSingleton(Object bean, String beanName) {
                // no application context has been injected which means the bean
                // has not been enlisted in Spring application context
View Full Code Here


    public void setCamelContext(SpringCamelContext camelContext) {
        this.camelContext = camelContext;
        postProcessor = new CamelPostProcessorHelper(camelContext) {
            @Override
            protected RuntimeException createProxyInstantiationRuntimeException(Class<?> type, Endpoint endpoint, Exception e) {
                return new BeanInstantiationException(type, "Could not instantiate proxy of type " + type.getName() + " on endpoint " + endpoint, e);
            }
        };
    }
View Full Code Here

        // Don't override the class with CGLIB if no overrides.
        if (beanDefinition.getMethodOverrides().isEmpty()) {
            Class clazz = beanDefinition.getBeanClass();
            if (clazz.isInterface()) {
                throw new BeanInstantiationException(clazz, "Specified class is an interface");
            }
            try {
                Constructor constructor = clazz.getDeclaredConstructor((Class[]) null);
                return BeanUtils.instantiateClass(constructor, null);
            }
            catch (Exception ex) {
                throw new BeanInstantiationException(clazz, "No default constructor found", ex);
            }
        } else {
            // Must generate CGLIB subclass.
            return instantiateWithMethodInjection(beanDefinition, beanName, owner);
        }
View Full Code Here

    public void setCamelContext(CamelContext camelContext) {
        this.camelContext = camelContext;
        postProcessor = new CamelPostProcessorHelper(camelContext) {
            @Override
            protected RuntimeException createProxyInstantiationRuntimeException(Class<?> type, Endpoint endpoint, Exception e) {
                return new BeanInstantiationException(type, "Could not instantiate proxy of type " + type.getName() + " on endpoint " + endpoint, e);
            }
        };
    }
View Full Code Here

        try {
          Constructor<?> enhancedSubclassConstructor = subclass.getConstructor(ctor.getParameterTypes());
          instance = enhancedSubclassConstructor.newInstance(args);
        }
        catch (Exception ex) {
          throw new BeanInstantiationException(this.beanDefinition.getBeanClass(),
              "Failed to invoke constructor for CGLIB enhanced subclass [" + subclass.getName() + "]", ex);
        }
      }
      // SPR-10785: set callbacks directly on the instance instead of in the
      // enhanced class (via the Enhancer) in order to avoid memory leaks.
View Full Code Here

      synchronized (bd.constructorArgumentLock) {
        constructorToUse = (Constructor<?>) bd.resolvedConstructorOrFactoryMethod;
        if (constructorToUse == null) {
          final Class<?> clazz = bd.getBeanClass();
          if (clazz.isInterface()) {
            throw new BeanInstantiationException(clazz, "Specified class is an interface");
          }
          try {
            if (System.getSecurityManager() != null) {
              constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>() {
                @Override
                public Constructor<?> run() throws Exception {
                  return clazz.getDeclaredConstructor((Class[]) null);
                }
              });
            }
            else {
              constructorToUse =  clazz.getDeclaredConstructor((Class[]) null);
            }
            bd.resolvedConstructorOrFactoryMethod = constructorToUse;
          }
          catch (Exception ex) {
            throw new BeanInstantiationException(clazz, "No default constructor found", ex);
          }
        }
      }
      return BeanUtils.instantiateClass(constructorToUse);
    }
View Full Code Here

          currentlyInvokedFactoryMethod.remove();
        }
      }
    }
    catch (IllegalArgumentException ex) {
      throw new BeanInstantiationException(factoryMethod.getReturnType(),
          "Illegal arguments to factory method '" + factoryMethod.getName() + "'; " +
          "args: " + StringUtils.arrayToCommaDelimitedString(args), ex);
    }
    catch (IllegalAccessException ex) {
      throw new BeanInstantiationException(factoryMethod.getReturnType(),
          "Cannot access factory method '" + factoryMethod.getName() + "'; is it public?", ex);
    }
    catch (InvocationTargetException ex) {
      String msg = "Factory method '" + factoryMethod.getName() + "' threw exception";
      if (bd.getFactoryBeanName() != null && owner instanceof ConfigurableBeanFactory &&
          ((ConfigurableBeanFactory) owner).isCurrentlyInCreation(bd.getFactoryBeanName())) {
        msg = "Circular reference involving containing bean '" + bd.getFactoryBeanName() + "' - consider " +
            "declaring the factory method as static for independence from its containing instance. " + msg;
      }
      throw new BeanInstantiationException(factoryMethod.getReturnType(), msg, ex.getTargetException());
    }
  }
View Full Code Here

    public void setCamelContext(CamelContext camelContext) {
        this.camelContext = camelContext;
        postProcessor = new CamelPostProcessorHelper(camelContext) {
            @Override
            protected RuntimeException createProxyInstantiationRuntimeException(Class<?> type, Endpoint endpoint, Exception e) {
                return new BeanInstantiationException(type, "Could not instantiate proxy of type " + type.getName() + " on endpoint " + endpoint, e);
            }
        };
    }
View Full Code Here

      synchronized (beanDefinition.constructorArgumentLock) {
        constructorToUse = (Constructor<?>) beanDefinition.resolvedConstructorOrFactoryMethod;
        if (constructorToUse == null) {
          final Class clazz = beanDefinition.getBeanClass();
          if (clazz.isInterface()) {
            throw new BeanInstantiationException(clazz, "Specified class is an interface");
          }
          try {
            if (System.getSecurityManager() != null) {
              constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor>() {
                public Constructor run() throws Exception {
                  return clazz.getDeclaredConstructor((Class[]) null);
                }
              });
            }
            else {
              constructorToUse =  clazz.getDeclaredConstructor((Class[]) null);
            }
            beanDefinition.resolvedConstructorOrFactoryMethod = constructorToUse;
          }
          catch (Exception ex) {
            throw new BeanInstantiationException(clazz, "No default constructor found", ex);
          }
        }
      }
      return BeanUtils.instantiateClass(constructorToUse);
    }
View Full Code Here

    } else if (shortName.equals("EmbeddedSolrServer")) {
      clone = cloneEmbeddedSolrServer(solrServer, core);
    }

    if (clone == null) {
      throw new BeanInstantiationException(solrServer.getClass(), "Cannot create instace of " + shortName + ".");
    }

    copyProperties(solrServer, clone);
    return (T) clone;
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.BeanInstantiationException

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.