Class ContainerException
- All Implemented Interfaces:
Serializable
This includes bean creation, dependency injection, and lifecycle management errors.
- Since:
- 6.2.0
- Author:
- wisdomme
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionContainerException(ErrorCode errorCode, String message) Creates a new container exception with a specific error code.ContainerException(ErrorCode errorCode, String message, Throwable cause) Creates a new container exception with error code, message, and cause.ContainerException(String message) Creates a new container exception with the given message.ContainerException(String message, Throwable cause) Creates a new container exception with message and cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic ContainerExceptionambiguousBeanType(Class<?> requestedType, Class<?> first, Class<?> second) Creates an exception for an ambiguous by-type bean resolution (D-11/D-12).static ContainerExceptionaopAnnotationOnPreConstructedBean(Class<?> beanClass, String location) Creates an exception refusing to register, viaregisterSingleton, an instance whose class carries an AOP annotation (@Transactionalor@ExceptionCatch) that can never take effect on it (D-15).static ContainerExceptionbeanNotFound(Class<?> beanType) Creates an exception for bean not found scenarios.static ContainerExceptionbeanNotFound(String beanName) Creates an exception for bean not found by name scenarios.static ContainerExceptioncircularDependency(String beanName) Creates an exception for circular dependency scenarios.static ContainerExceptionduplicateBean(String beanName, Class<?> beanType) Creates an exception for duplicate bean definitions.static ContainerExceptioninjectionFailed(Class<?> targetType, Class<?> dependencyType, Throwable cause) Creates an exception for dependency injection failures.static ContainerExceptionmalformedAliasFor(Class<? extends Annotation> declaringAnnotation, String attribute, String reason) Creates an exception for a malformed@AliasFordeclaration -- one that fails one of Spring's documented Implementation Requirements for an explicit meta-annotation alias (D-02).static ContainerExceptionCreates an exception for an unresolvable@Autowired(required = true)field (D-08).Methods inherited from class com.ultikits.ultitools.exceptions.UltiToolsException
getErrorCode, getFormattedMessage, toStringMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
ContainerException
Creates a new container exception with the given message.- Parameters:
message- the error message
-
ContainerException
Creates a new container exception with a specific error code.- Parameters:
errorCode- the error codemessage- the error message
-
ContainerException
Creates a new container exception with message and cause.- Parameters:
message- the error messagecause- the underlying cause
-
ContainerException
Creates a new container exception with error code, message, and cause.- Parameters:
errorCode- the error codemessage- the error messagecause- the underlying cause
-
-
Method Details
-
beanNotFound
Creates an exception for bean not found scenarios.- Parameters:
beanType- the type of bean that was not found- Returns:
- a new ContainerException
-
beanNotFound
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
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 intodependencyType- the type of the dependency that could not be injectedcause- the underlying cause- Returns:
- a new ContainerException
-
duplicateBean
Creates an exception for duplicate bean definitions.- Parameters:
beanName- the name of the duplicate beanbeanType- 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@AliasFordeclaration -- 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@AliasForattribute- the offending attribute's namereason- a specific reason clause describing which requirement failed- Returns:
- a new ContainerException
-
requiredDependencyUnresolved
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'sscanBasePackages, that the owning object was created by the container rather than withnew, 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, sogetBean(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 classsecond- 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, viaregisterSingleton, an instance whose class carries an AOP annotation (@Transactionalor@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 refusedlocation- the offending method's"ClassName#methodName", or the literal"class-level"when the annotation was found at class level- Returns:
- a new ContainerException
-