01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.beans.factory;
18:
19: import org.springframework.beans.FatalBeanException;
20:
21: /**
22: * Exception thrown when the BeanFactory cannot load the specified class
23: * of a given bean.
24: *
25: * @author Juergen Hoeller
26: * @since 2.0
27: */
28: public class CannotLoadBeanClassException extends FatalBeanException {
29:
30: private String resourceDescription;
31:
32: private String beanName;
33:
34: private String beanClassName;
35:
36: /**
37: * Create a new CannotLoadBeanClassException.
38: * @param resourceDescription description of the resource
39: * that the bean definition came from
40: * @param beanName the name of the bean requested
41: * @param beanClassName the name of the bean class
42: * @param cause the root cause
43: */
44: public CannotLoadBeanClassException(String resourceDescription,
45: String beanName, String beanClassName,
46: ClassNotFoundException cause) {
47:
48: super ("Cannot find class [" + beanClassName
49: + "] for bean with name '" + beanName + "' defined in "
50: + resourceDescription, cause);
51: this .resourceDescription = resourceDescription;
52: this .beanName = beanName;
53: this .beanClassName = beanClassName;
54: }
55:
56: /**
57: * Create a new CannotLoadBeanClassException.
58: * @param resourceDescription description of the resource
59: * that the bean definition came from
60: * @param beanName the name of the bean requested
61: * @param beanClassName the name of the bean class
62: * @param cause the root cause
63: */
64: public CannotLoadBeanClassException(String resourceDescription,
65: String beanName, String beanClassName, LinkageError cause) {
66:
67: super ("Error loading class [" + beanClassName
68: + "] for bean with name '" + beanName + "' defined in "
69: + resourceDescription
70: + ": problem with class file or dependent class", cause);
71: this .resourceDescription = resourceDescription;
72: this .beanName = beanName;
73: this .beanClassName = beanClassName;
74: }
75:
76: /**
77: * Return the description of the resource that the bean
78: * definition came from.
79: */
80: public String getResourceDescription() {
81: return this .resourceDescription;
82: }
83:
84: /**
85: * Return the name of the bean requested.
86: */
87: public String getBeanName() {
88: return this .beanName;
89: }
90:
91: /**
92: * Return the name of the class we were trying to load.
93: */
94: public String getBeanClassName() {
95: return this.beanClassName;
96: }
97:
98: }
|