BeanCurrentlyInCreationException class

The error thrown when beans depend on each other in a cycle, so none of them can be created first.

cycle lists the beans in order. It is a BeanCreationException.

Unlike Spring, cycles are always rejected (there are no early references); validateBeanGraph reports them at refresh before any bean is created. A cycle found while beans are being created is wrapped, like any creation error, in the exceptions of the beans being created (see BeansException.rootCause). Break a cycle with @Lazy() or ObjectProvider<T>.

// Bean a injects b and b injects a.
try {
  context.refresh();
} on BeanCurrentlyInCreationException catch (e) {
  log.error(e.cycle); // [a, b, a]
}

Spring (Java):

try {
  context.refresh();
} catch (BeanCurrentlyInCreationException e) {
  log.error(e.getBeanName());
}
Inheritance

Constructors

BeanCurrentlyInCreationException(List<String> cycle)
The beans named in cycle depend on each other in a cycle.
BeanCurrentlyInCreationException.factoryProduct(List<String> cycle)
The product of the FactoryBean named cycle.first was requested again while its getObject() was creating it.

Properties

beanName → String
The bean whose creation failed.
finalinherited
cause → Object?
The error that caused this one, if any: what a constructor threw, or the container error of a nested bean.
finalinherited
causeStackTrace → StackTrace
The stack trace of cause (empty without a cause).
finalinherited
cycle → List<String>
Bean names forming the cycle; the first and last are the same bean (beanName, the bean requested again).
final
hashCode → int
The hash code for this object.
no setterinherited
message → String
A human-readable description of the problem.
finalinherited
mostSpecificCause → Object
rootCause, or this exception when it has no cause. Spring: getMostSpecificCause().
no setterinherited
rootCause → Object?
The innermost cause: cause followed through nested container errors, or null without a cause. Usually the error that really went wrong. Spring: getRootCause().
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited