org.springframework.beans.factory

## Class BeanNotOfRequiredTypeException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - org.springframework.core.NestedRuntimeException
        - - org.springframework.beans.BeansException
          - - org.springframework.beans.factory.BeanNotOfRequiredTypeException

- All Implemented Interfaces:
    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(String beanName, Class requiredType, Class actualType)` Create a new BeanNotOfRequiredTypeException.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Class` | `getActualType()` Return the actual type of the instance found.
    `String` | `getBeanName()` Return the name of the instance that was of the wrong type.
    `Class` | `getRequiredType()` Return the expected type for the bean.

    - ### Methods inherited from class org.springframework.beans.BeansException

      `equals, hashCode`

    - ### Methods inherited from class org.springframework.core.NestedRuntimeException

      `contains, getMessage, getMostSpecificCause, getRootCause`

    - ### 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, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### BeanNotOfRequiredTypeException

          public BeanNotOfRequiredTypeException(String beanName,
                                        Class requiredType,
                                        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 String getBeanName()

      Return the name of the instance that was of the wrong type.

    - #### getRequiredType

          public Class getRequiredType()

      Return the expected type for the bean.

    - #### getActualType

          public Class getActualType()

      Return the actual type of the instance found.