Class ContainerException

All Implemented Interfaces:
Serializable

public class ContainerException extends UltiToolsException
Exception thrown when IoC container operations fail.

This includes bean creation, dependency injection, and lifecycle management errors.

Since:
6.2.0
Author:
wisdomme
See Also:
  • Constructor Details

    • ContainerException

      public ContainerException(String message)
      Creates a new container exception with the given message.
      Parameters:
      message - the error message
    • ContainerException

      public ContainerException(ErrorCode errorCode, String message)
      Creates a new container exception with a specific error code.
      Parameters:
      errorCode - the error code
      message - the error message
    • ContainerException

      public ContainerException(String message, Throwable cause)
      Creates a new container exception with message and cause.
      Parameters:
      message - the error message
      cause - the underlying cause
    • ContainerException

      public ContainerException(ErrorCode errorCode, String message, Throwable cause)
      Creates a new container exception with error code, message, and cause.
      Parameters:
      errorCode - the error code
      message - the error message
      cause - the underlying cause
  • Method Details

    • beanNotFound

      public static ContainerException beanNotFound(Class<?> beanType)
      Creates an exception for bean not found scenarios.
      Parameters:
      beanType - the type of bean that was not found
      Returns:
      a new ContainerException
    • beanNotFound

      public static ContainerException beanNotFound(String beanName)
      Creates an exception for bean not found by name scenarios.
      Parameters:
      beanName - the name of the bean that was not found
      Returns:
      a new ContainerException
    • circularDependency

      public static ContainerException circularDependency(String beanName)
      Creates an exception for circular dependency scenarios.
      Parameters:
      beanName - the bean involved in the circular dependency
      Returns:
      a new ContainerException
    • injectionFailed

      public static ContainerException injectionFailed(Class<?> targetType, Class<?> dependencyType, Throwable cause)
      Creates an exception for dependency injection failures.
      Parameters:
      targetType - the type being injected into
      dependencyType - the type of the dependency that could not be injected
      cause - the underlying cause
      Returns:
      a new ContainerException
    • duplicateBean

      public static ContainerException duplicateBean(String beanName, Class<?> beanType)
      Creates an exception for duplicate bean definitions.
      Parameters:
      beanName - the name of the duplicate bean
      beanType - the type of the bean
      Returns:
      a new ContainerException
    • malformedAliasFor

      public static ContainerException malformedAliasFor(Class<? extends Annotation> declaringAnnotation, String attribute, String reason)
      Creates an exception for a malformed @AliasFor declaration -- one that fails one of Spring's documented Implementation Requirements for an explicit meta-annotation alias (D-02). The message always names both the declaring annotation and the offending attribute, so the module author can act on it without cross-referencing anything else.
      Parameters:
      declaringAnnotation - the annotation type that declares the malformed @AliasFor
      attribute - the offending attribute's name
      reason - a specific reason clause describing which requirement failed
      Returns:
      a new ContainerException
    • requiredDependencyUnresolved

      public static ContainerException requiredDependencyUnresolved(Field field)
      Creates an exception for an unresolvable @Autowired(required = true) field (D-08).

      The message names both the dependency's type and the field's declaring class plus field name, and repeats the same actionable guidance the earlier warning-only diagnostic gave: check the target is annotated @Service/@Component, that it is inside the module's scanBasePackages, that the owning object was created by the container rather than with new, and that @Autowired(required = false) exists for genuinely optional dependencies.

      Parameters:
      field - the field whose dependency could not be resolved
      Returns:
      a new ContainerException
    • ambiguousBeanType

      public static ContainerException ambiguousBeanType(Class<?> requestedType, Class<?> first, Class<?> second)
      Creates an exception for an ambiguous by-type bean resolution (D-11/D-12).

      Two or more candidates assignable to the requested type share the highest @Service(priority) value, so getBean(Class) cannot determine which one the caller intended. Before this check existed, the ambiguity was resolved silently by whichever candidate the internal map iteration reached first, and that arbitrary choice was then cached permanently. The message names both tied candidate classes and the requested type, and points at @Service(priority = ...) as the remedy.

      Parameters:
      requestedType - the type that was requested via getBean(Class)
      first - the first tied candidate's class
      second - the second tied candidate's class
      Returns:
      a new ContainerException
    • aopAnnotationOnPreConstructedBean

      public static ContainerException aopAnnotationOnPreConstructedBean(Class<?> beanClass, String location)
      Creates an exception refusing to register, via registerSingleton, an instance whose class carries an AOP annotation (@Transactional or @ExceptionCatch) that can never take effect on it (D-15).

      A ByteBuddy proxy is the bean itself in this framework's design -- there is no separate delegate target -- so a proxy can never be retrofitted onto an object the caller already constructed. Before this refusal existed, the annotation was silently inert: the method ran completely unprotected/untransacted, with no signal that anything was wrong. An instance that is already a generated proxy (ProxyFactory.isProxyClass) is never passed here -- it already honours its own annotations and is exempt from this check entirely.

      Parameters:
      beanClass - the class of the pre-constructed instance that was refused
      location - the offending method's "ClassName#methodName", or the literal "class-level" when the annotation was found at class level
      Returns:
      a new ContainerException