org.springframework.beans.factory

Class BeanNotOfRequiredTypeException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    BeanIsNotAFactoryException


    public class BeanNotOfRequiredTypeException
    extends BeansException
    Thrown when a bean doesn't match the expected type.
    Author:
    Rod Johnson, Juergen Hoeller
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      BeanNotOfRequiredTypeException(java.lang.String beanName, java.lang.Class<?> requiredType, java.lang.Class<?> actualType)
      Create a new BeanNotOfRequiredTypeException.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Class<?> getActualType()
      Return the actual type of the instance found.
      java.lang.String getBeanName()
      Return the name of the instance that was of the wrong type.
      java.lang.Class<?> getRequiredType()
      Return the expected type for the bean.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • BeanNotOfRequiredTypeException

        public BeanNotOfRequiredTypeException(java.lang.String beanName,
                                              java.lang.Class<?> requiredType,
                                              java.lang.Class<?> actualType)
        Create a new BeanNotOfRequiredTypeException.
        Parameters:
        beanName - the name of the bean requested
        requiredType - the required type
        actualType - the actual type returned, which did not match the expected type
    • Method Detail

      • getBeanName

        public java.lang.String getBeanName()
        Return the name of the instance that was of the wrong type.
      • getRequiredType

        public java.lang.Class<?> getRequiredType()
        Return the expected type for the bean.
      • getActualType

        public java.lang.Class<?> getActualType()
        Return the actual type of the instance found.