Top Description Fields Constructors Methods
org.springframework.beans.factory

public Class BeanCreationException

extends FatalBeanException
Class Inheritance
Known Direct Subclasses
org.springframework.beans.factory.BeanCreationNotAllowedException, org.springframework.beans.factory.BeanCurrentlyInCreationException, org.springframework.beans.factory.BeanIsAbstractException, org.springframework.beans.factory.UnsatisfiedDependencyException, org.springframework.beans.factory.support.ScopeNotActiveException
Annotations
@SuppressWarnings:serial
Imports
java.io.PrintStream, .PrintWriter, java.util.ArrayList, .List, org.springframework.beans.FatalBeanException, org.springframework.core.NestedRuntimeException, org.springframework.lang.Nullable

Exception thrown when a BeanFactory encounters an error when attempting to create a bean from a bean definition.
Author
Juergen Hoeller

Field Summary

Modifier and TypeField and Description
private final String
private List<Throwable>
private final String

Constructor Summary

AccessConstructor and Description
public
BeanCreationException(String
the detail message
msg
)

Create a new BeanCreationException.

public
BeanCreationException(String
the detail message
msg
,
Throwable
the root cause
cause
)

Create a new BeanCreationException.

public
BeanCreationException(String
the name of the bean requested
beanName
,
String
the detail message
msg
)

Create a new BeanCreationException.

public
BeanCreationException(String
the name of the bean requested
beanName
,
String
the detail message
msg
,
Throwable
the root cause
cause
)

Create a new BeanCreationException.

public
BeanCreationException(String
description of the resource that the bean definition came from
resourceDescription
,
String
the name of the bean requested
beanName
,
String
the detail message
msg
)

Create a new BeanCreationException.

public
BeanCreationException(String
description of the resource that the bean definition came from
resourceDescription
,
String
the name of the bean requested
beanName
,
String
the detail message
msg
,
Throwable
the root cause
cause
)

Create a new BeanCreationException.

Method Summary

Modifier and TypeMethod and Description
public void
addRelatedCause(Throwable
the related cause to add
ex
)

Add a related cause to this bean creation exception, not being a direct cause of the failure but having occurred earlier in the creation of the same bean instance.

public boolean
contains(Class<?>
the exception type to look for
exClass
)

Overrides org.springframework.core.NestedRuntimeException.contains.

Check whether this exception contains an exception of the given type: either it is of the given class itself or it contains a nested cause of the given type.
public String
getBeanName()

Return the name of the bean requested, if any.

public Throwable[]

Returns:

the array of related causes, or null if none
getRelatedCauses
()

Return the related causes, if any.

public String
getResourceDescription()

Return the description of the resource that the bean definition came from, if any.

public void
printStackTrace(PrintStream
PrintStream to use for output
ps
)

Overrides java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print stream.
public void
printStackTrace(PrintWriter
PrintWriter to use for output
pw
)

Overrides java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print writer.
public String
toString()

Overrides java.lang.Throwable.toString.

Returns a short description of this throwable.

Field Detail

beanNameback to summary
private final String beanName
Annotations
@Nullable
relatedCausesback to summary
private List<Throwable> relatedCauses
Annotations
@Nullable
resourceDescriptionback to summary
private final String resourceDescription
Annotations
@Nullable

Constructor Detail

BeanCreationExceptionback to summary
public BeanCreationException(String msg)

Create a new BeanCreationException.

Parameters
msg:String

the detail message

BeanCreationExceptionback to summary
public BeanCreationException(String msg, Throwable cause)

Create a new BeanCreationException.

Parameters
msg:String

the detail message

cause:Throwable

the root cause

BeanCreationExceptionback to summary
public BeanCreationException(String beanName, String msg)

Create a new BeanCreationException.

Parameters
beanName:String

the name of the bean requested

msg:String

the detail message

BeanCreationExceptionback to summary
public BeanCreationException(String beanName, String msg, Throwable cause)

Create a new BeanCreationException.

Parameters
beanName:String

the name of the bean requested

msg:String

the detail message

cause:Throwable

the root cause

BeanCreationExceptionback to summary
public BeanCreationException(String resourceDescription, String beanName, String msg)

Create a new BeanCreationException.

Parameters
resourceDescription:String

description of the resource that the bean definition came from

beanName:String

the name of the bean requested

msg:String

the detail message

BeanCreationExceptionback to summary
public BeanCreationException(String resourceDescription, String beanName, String msg, Throwable cause)

Create a new BeanCreationException.

Parameters
resourceDescription:String

description of the resource that the bean definition came from

beanName:String

the name of the bean requested

msg:String

the detail message

cause:Throwable

the root cause

Method Detail

addRelatedCauseback to summary
public void addRelatedCause(Throwable ex)

Add a related cause to this bean creation exception, not being a direct cause of the failure but having occurred earlier in the creation of the same bean instance.

Parameters
ex:Throwable

the related cause to add

containsback to summary
public boolean contains(Class<?> exClass)

Overrides org.springframework.core.NestedRuntimeException.contains.

Doc from org.springframework.core.NestedRuntimeException.contains.

Check whether this exception contains an exception of the given type: either it is of the given class itself or it contains a nested cause of the given type.

Parameters
exClass:Class<?>

the exception type to look for

Returns:boolean

whether there is a nested exception of the specified type

Annotations
@Override
getBeanNameback to summary
public String getBeanName()

Return the name of the bean requested, if any.

Annotations
@Nullable
getRelatedCausesback to summary
public Throwable[] getRelatedCauses()

Return the related causes, if any.

Returns:Throwable[]

the array of related causes, or null if none

Annotations
@Nullable
getResourceDescriptionback to summary
public String getResourceDescription()

Return the description of the resource that the bean definition came from, if any.

Annotations
@Nullable
printStackTraceback to summary
public void printStackTrace(PrintStream ps)

Overrides java.lang.Throwable.printStackTrace.

Doc from java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print stream.

Parameters
ps:PrintStream

PrintStream to use for output

Annotations
@Override
printStackTraceback to summary
public void printStackTrace(PrintWriter pw)

Overrides java.lang.Throwable.printStackTrace.

Doc from java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print writer.

Parameters
pw:PrintWriter

PrintWriter to use for output

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Throwable.toString.

Doc from java.lang.Throwable.toString.

Returns a short description of this throwable. The result is the concatenation of:

  • the name of the class of this object
  • ": " (a colon and a space)
  • the result of invoking this object's getLocalizedMessage method
If getLocalizedMessage returns null, then just the class name is returned.
Returns:String

a string representation of this throwable.

Annotations
@Override