Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.UnsatisfiedDependencyException


      try {
        resolvedArgs[argIndex] = converter.convertIfNecessary(argValue, paramType, methodParam);
      }
      catch (TypeMismatchException ex) {
        String methodType = (methodOrCtor instanceof Constructor ? "constructor" : "factory method");
        throw new UnsatisfiedDependencyException(
            mbd.getResourceDescription(), beanName, argIndex, paramType,
            "Could not convert " + methodType + " argument value of type [" +
            ObjectUtils.nullSafeClassName(argValue) +
            "] to required type [" + paramType.getName() + "]: " + ex.getMessage());
      }
View Full Code Here


          }
        }
        autowiredBeanNames.clear();
      }
      catch (BeansException ex) {
        throw new UnsatisfiedDependencyException(mbd.getResourceDescription(), beanName, propertyName, ex);
      }
    }
  }
View Full Code Here

        boolean isSimple = BeanUtils.isSimpleProperty(pd.getPropertyType());
        boolean unsatisfied = (dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_ALL) ||
            (isSimple && dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_SIMPLE) ||
            (!isSimple && dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
        if (unsatisfied) {
          throw new UnsatisfiedDependencyException(mbd.getResourceDescription(), beanName, pd.getName(),
              "Set this property value or disable dependency checking for this bean.");
        }
      }
    }
  }
View Full Code Here

              resolveNecessary = true;
              args.preparedArguments[index] = sourceValue;
            }
          }
          catch (TypeMismatchException ex) {
            throw new UnsatisfiedDependencyException(
                mbd.getResourceDescription(), beanName, index, paramTypes[index],
                "Could not convert " + methodType + " argument value of type [" +
                ObjectUtils.nullSafeClassName(valueHolder.getValue()) +
                "] to required type [" + paramTypes[index].getName() + "]: " + ex.getMessage());
          }
        }
      }
      else {
        // No explicit match found: we're either supposed to autowire or
        // have to fail creating an argument array for the given constructor.
        if (!autowiring) {
          throw new UnsatisfiedDependencyException(
              mbd.getResourceDescription(), beanName, index, paramTypes[index],
              "Ambiguous " + methodType + " argument types - " +
              "did you specify the correct bean references as " + methodType + " arguments?");
        }
        Map matchingBeans = findAutowireCandidates(beanName, paramTypes[index]);
        if (matchingBeans.size() != 1) {
          throw new UnsatisfiedDependencyException(
              mbd.getResourceDescription(), beanName, index, paramTypes[index],
              "There are " + matchingBeans.size() + " beans of type [" + paramTypes[index].getName() +
              "] available for autowiring: " + matchingBeans.keySet() +
              ". There should have been exactly 1 to be able to autowire " +
              methodType + " of bean '" + beanName + "'.");
View Full Code Here

          logger.debug("Autowiring by type from bean name '" + beanName + "' via property '" +
              propertyName + "' to bean named '" + autowiredBeanName + "'");
        }
      }
      else if (count > 1) {
        throw new UnsatisfiedDependencyException(
            mbd.getResourceDescription(), beanName, propertyName,
            "There are " + matchingBeans.size() + " beans of type [" + requiredType.getName() +
            "] available for autowiring by type: " + matchingBeans.keySet() +
            ". There should have been exactly 1 to be able to autowire property '" +
            propertyName + "' of bean '" + beanName + "'. Consider using autowiring by name instead.");
View Full Code Here

        boolean isSimple = BeanUtils.isSimpleProperty(pds[i].getPropertyType());
        boolean unsatisfied = (dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_ALL) ||
          (isSimple && dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_SIMPLE) ||
          (!isSimple && dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
        if (unsatisfied) {
          throw new UnsatisfiedDependencyException(
              mbd.getResourceDescription(), beanName, pds[i].getName(),
              "Set this property value or disable dependency checking for this bean.");
        }
      }
    }
View Full Code Here

          }
        }
        autowiredBeanNames.clear();
      }
      catch (BeansException ex) {
        throw new UnsatisfiedDependencyException(mbd.getResourceDescription(), beanName, propertyName, ex);
      }
    }
  }
View Full Code Here

        boolean isSimple = BeanUtils.isSimpleProperty(pds[i].getPropertyType());
        boolean unsatisfied = (dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_ALL) ||
          (isSimple && dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_SIMPLE) ||
          (!isSimple && dependencyCheck == RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
        if (unsatisfied) {
          throw new UnsatisfiedDependencyException(
              mbd.getResourceDescription(), beanName, pds[i].getName(),
              "Set this property value or disable dependency checking for this bean.");
        }
      }
    }
View Full Code Here

              resolveNecessary = true;
              args.preparedArguments[paramIndex] = sourceValue;
            }
          }
          catch (TypeMismatchException ex) {
            throw new UnsatisfiedDependencyException(
                mbd.getResourceDescription(), beanName, paramIndex, paramType,
                "Could not convert " + methodType + " argument value of type [" +
                ObjectUtils.nullSafeClassName(valueHolder.getValue()) +
                "] to required type [" + paramType.getName() + "]: " + ex.getMessage());
          }
        }
      }
      else {
        // No explicit match found: we're either supposed to autowire or
        // have to fail creating an argument array for the given constructor.
        if (!autowiring) {
          throw new UnsatisfiedDependencyException(
              mbd.getResourceDescription(), beanName, paramIndex, paramType,
              "Ambiguous " + methodType + " argument types - " +
              "did you specify the correct bean references as " + methodType + " arguments?");
        }
        try {
          MethodParameter param = MethodParameter.forMethodOrConstructor(methodOrCtor, paramIndex);
          Object autowiredArgument = resolveAutowiredArgument(param, beanName, autowiredBeanNames, converter);
          args.rawArguments[paramIndex] = autowiredArgument;
          args.arguments[paramIndex] = autowiredArgument;
          args.preparedArguments[paramIndex] = new AutowiredArgumentMarker();
          resolveNecessary = true;
        }
        catch (BeansException ex) {
          throw new UnsatisfiedDependencyException(
              mbd.getResourceDescription(), beanName, paramIndex, paramType, ex);
        }
      }
    }
View Full Code Here

          }
        }
        autowiredBeanNames.clear();
      }
      catch (BeansException ex) {
        throw new UnsatisfiedDependencyException(mbd.getResourceDescription(), beanName, propertyName, ex);
      }
    }
  }
View Full Code Here

TOP

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

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.