Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2002-2007 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.springframework.beans.factory;
 
 import java.util.List;
 
Exception thrown when a BeanFactory encounters an error when attempting to create a bean from a bean definition.

Author(s):
Juergen Hoeller
 
 public class BeanCreationException extends FatalBeanException {
 
 	private String beanName;
 
 
 	private List relatedCauses;


Create a new BeanCreationException.

Parameters:
msg the detail message
 
 	public BeanCreationException(String msg) {
 		super(msg);
 	}

Create a new BeanCreationException.

Parameters:
msg the detail message
cause the root cause
 
 	public BeanCreationException(String msgThrowable cause) {
 		super(msgcause);
 	}

Create a new BeanCreationException.

Parameters:
beanName the name of the bean requested
msg the detail message
 
 	public BeanCreationException(String beanNameString msg) {
 		this(beanNamemsg, (Throwablenull);
 	}

Create a new BeanCreationException.

Parameters:
beanName the name of the bean requested
msg the detail message
cause the root cause
 
 	public BeanCreationException(String beanNameString msgThrowable cause) {
 		super("Error creating bean with name '" + beanName + "': " + msgcause);
 		this. = 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 resourceDescriptionString beanNameString msg) {
 		this(resourceDescriptionbeanNamemsgnull);
 	}

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
 
 	public BeanCreationException(String resourceDescriptionString beanNameString msgThrowable cause) {
		super("Error creating bean with name '" + beanName + "'" +
				(resourceDescription != null ? " defined in " + resourceDescription : "") +
				": " + msgcause);
		this. = resourceDescription;
		this. = beanName;
	}


Return the name of the bean requested, if any.
	public String getBeanName() {
		return this.;
	}

Return the description of the resource that the bean definition came from, if any.
		return this.;
	}

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.

Parameters:
ex the related cause to add
	public void addRelatedCause(Throwable ex) {
		if (this. == null) {
			this. = new LinkedList();
		}
	}

Return the related causes, if any.

Returns:
the array of related causes, or null if none
		if (this. == null) {
			return null;
		}
		return (Throwable[]) this..toArray(new Throwable[this..size()]);
	}
	public String toString() {
		StringBuffer sb = new StringBuffer(super.toString());
		if (this. != null) {
			for (Iterator it = this..iterator(); it.hasNext();) {
				Throwable relatedCause = (Throwableit.next();
				sb.append("\nRelated cause: ");
				sb.append(relatedCause);
			}
		}
		return sb.toString();
	}
	public void printStackTrace(PrintStream ps) {
		synchronized (ps) {
			super.printStackTrace(ps);
			if (this. != null) {
				for (Iterator it = this..iterator(); it.hasNext();) {
					Throwable relatedCause = (Throwableit.next();
					ps.println("Related cause:");
					relatedCause.printStackTrace(ps);
				}
			}
		}
	}
	public void printStackTrace(PrintWriter pw) {
		synchronized (pw) {
			super.printStackTrace(pw);
			if (this. != null) {
				for (Iterator it = this..iterator(); it.hasNext();) {
					Throwable relatedCause = (Throwableit.next();
					pw.println("Related cause:");
					relatedCause.printStackTrace(pw);
				}
			}
		}
	}
	public boolean contains(Class exClass) {
		if (super.contains(exClass)) {
			return true;
		}
		if (this. != null) {
			for (Iterator it = this..iterator(); it.hasNext();) {
				Throwable relatedCause = (Throwableit.next();
				if (relatedCause instanceof NestedRuntimeException &&
						((NestedRuntimeExceptionrelatedCause).contains(exClass)) {
					return true;
				}
			}
		}
		return false;
	}
New to GrepCode? Check out our FAQ X