Examples of BeanInstantiationException


Examples of org.springframework.beans.BeanInstantiationException

        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

Examples of org.springframework.beans.BeanInstantiationException

      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

Examples of org.springframework.beans.BeanInstantiationException

          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

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);
            }
        };
    }
View Full Code Here

Examples of org.springframework.beans.BeanInstantiationException

      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

Examples of org.springframework.beans.BeanInstantiationException

    } 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

Examples of org.springframework.beans.BeanInstantiationException

    try {
      Constructor constructor = ClassUtils.getConstructorIfAvailable(solrServer.getClass(), CoreContainer.class,
          String.class);
      return (SolrServer) BeanUtils.instantiateClass(constructor, coreContainer, core);
    } catch (Exception e) {
      throw new BeanInstantiationException(solrServer.getClass(), "Cannot create instace of " + solrServer.getClass()
          + ".", e);
    }
  }
View Full Code Here

Examples of org.springframework.beans.BeanInstantiationException

      Constructor<? extends SolrServer> constructor = (Constructor<? extends SolrServer>) ClassUtils
          .getConstructorIfAvailable(solrServer.getClass(), String.class);
      return (SolrServer) BeanUtils.instantiateClass(constructor, url);
    } catch (Exception e) {
      throw new BeanInstantiationException(solrServer.getClass(), "Cannot create instace of " + solrServer.getClass()
          + ". ", e);
    }
  }
View Full Code Here

Examples of org.springframework.beans.BeanInstantiationException

        clone = cloneSolr3LBHttpServer(solrServer, core);
      } else if (VersionUtil.isSolr4XAvailable()) {
        clone = cloneSolr4LBHttpServer(solrServer, core);
      }
    } catch (Exception e) {
      throw new BeanInstantiationException(solrServer.getClass(), "Cannot create instace of " + solrServer.getClass()
          + ". ", e);
    }
    Object o = readField(solrServer, "interval");
    if (o != null) {
      clone.setAliveCheckInterval(Integer.valueOf(o.toString()).intValue());
View Full Code Here

Examples of org.springframework.beans.BeanInstantiationException

  protected void initSolrServer() {
    try {
      this.solrServer = createPathConfiguredSolrServer(this.solrHome);
    } catch (ParserConfigurationException e) {
      throw new BeanInstantiationException(EmbeddedSolrServer.class, e.getMessage(), e);
    } catch (IOException e) {
      throw new BeanInstantiationException(EmbeddedSolrServer.class, e.getMessage(), e);
    } catch (SAXException e) {
      throw new BeanInstantiationException(EmbeddedSolrServer.class, e.getMessage(), e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.