Exception thrown when a BeanFactory encounters an error when
attempting to create a bean from a bean definition.
| Constructor: |
public BeanCreationException(String msg) {
super(msg);
}
Create a new BeanCreationException. Parameters:
msg - the detail message
|
public BeanCreationException(String msg,
Throwable cause) {
super(msg, cause);
}
Create a new BeanCreationException. Parameters:
msg - the detail message
cause - the root cause
|
public BeanCreationException(String beanName,
String msg) {
super("Error creating bean with name '" + beanName + "': " + msg);
this.beanName = beanName;
}
Create a new BeanCreationException. Parameters:
beanName - the name of the bean requested
msg - the detail message
|
public BeanCreationException(String beanName,
String msg,
Throwable cause) {
this(beanName, msg);
initCause(cause);
}
Create a new BeanCreationException. Parameters:
beanName - the name of the bean requested
msg - the detail message
cause - the root cause
|
public BeanCreationException(String resourceDescription,
String beanName,
String msg) {
super("Error creating bean with name '" + beanName + "'" +
(resourceDescription != null ? " defined in " + resourceDescription : "") + ": " + msg);
this.resourceDescription = resourceDescription;
this.beanName = beanName;
}
Create a new BeanCreationException. Parameters:
resourceDescription - description of the resource
that the bean definition came from
beanName - the name of the bean requested
msg - the detail message
|
public BeanCreationException(String resourceDescription,
String beanName,
String msg,
Throwable cause) {
this(resourceDescription, beanName, msg);
initCause(cause);
}
Create a new BeanCreationException. Parameters:
resourceDescription - description of the resource
that the bean definition came from
beanName - the name of the bean requested
msg - the detail message
cause - the root cause
|
| Method from org.springframework.beans.factory.BeanCreationException Detail: |
public void addRelatedCause(Throwable ex) {
if (this.relatedCauses == null) {
this.relatedCauses = new LinkedList();
}
this.relatedCauses.add(ex);
}
Add a related cause to this bean creation exception,
not being a direct cause of the failure but having occured
earlier in the creation of the same bean instance. |
public boolean contains(Class exClass) {
if (super.contains(exClass)) {
return true;
}
if (this.relatedCauses != null) {
for (Iterator it = this.relatedCauses.iterator(); it.hasNext();) {
Throwable relatedCause = (Throwable) it.next();
if (relatedCause instanceof NestedRuntimeException &&
((NestedRuntimeException) relatedCause).contains(exClass)) {
return true;
}
}
}
return false;
}
|
public String getBeanName() {
return this.beanName;
}
Return the name of the bean requested, if any. |
public Throwable[] getRelatedCauses() {
if (this.relatedCauses == null) {
return null;
}
return (Throwable[]) this.relatedCauses.toArray(new Throwable[this.relatedCauses.size()]);
}
Return the related causes, if any. |
public String getResourceDescription() {
return this.resourceDescription;
}
Return the description of the resource that the bean
definition came from, if any. |
public void printStackTrace(PrintStream ps) {
synchronized (ps) {
super.printStackTrace(ps);
if (this.relatedCauses != null) {
for (Iterator it = this.relatedCauses.iterator(); it.hasNext();) {
Throwable relatedCause = (Throwable) it.next();
ps.println("Related cause:");
relatedCause.printStackTrace(ps);
}
}
}
}
|
public void printStackTrace(PrintWriter pw) {
synchronized (pw) {
super.printStackTrace(pw);
if (this.relatedCauses != null) {
for (Iterator it = this.relatedCauses.iterator(); it.hasNext();) {
Throwable relatedCause = (Throwable) it.next();
pw.println("Related cause:");
relatedCause.printStackTrace(pw);
}
}
}
}
|
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
if (this.relatedCauses != null) {
for (Iterator it = this.relatedCauses.iterator(); it.hasNext();) {
Throwable relatedCause = (Throwable) it.next();
sb.append("\nRelated cause: ");
sb.append(relatedCause);
}
}
return sb.toString();
}
|