KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > CannotLoadBeanClassException


1 /*
2  * Copyright 2002-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc resourceDescription;
31
32     private String JavaDoc beanName;
33
34     private String JavaDoc beanClassName;
35
36
37     /**
38      * Create a new CannotLoadBeanClassException.
39      * @param resourceDescription description of the resource
40      * that the bean definition came from
41      * @param beanName the name of the bean requested
42      * @param beanClassName the name of the bean class
43      * @param cause the root cause
44      */

45     public CannotLoadBeanClassException(
46             String JavaDoc resourceDescription, String JavaDoc beanName, String JavaDoc beanClassName, ClassNotFoundException JavaDoc cause) {
47
48         super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName +
49                 "' defined in " + resourceDescription, cause);
50         this.resourceDescription = resourceDescription;
51         this.beanName = beanName;
52         this.beanClassName = beanClassName;
53     }
54
55     /**
56      * Create a new CannotLoadBeanClassException.
57      * @param resourceDescription description of the resource
58      * that the bean definition came from
59      * @param beanName the name of the bean requested
60      * @param beanClassName the name of the bean class
61      * @param cause the root cause
62      */

63     public CannotLoadBeanClassException(
64             String JavaDoc resourceDescription, String JavaDoc beanName, String JavaDoc beanClassName, LinkageError JavaDoc cause) {
65
66         super("Error loading class [" + beanClassName + "] for bean with name '" + beanName +
67                 "' defined in " + resourceDescription + ": problem with class file or dependent class", cause);
68         this.resourceDescription = resourceDescription;
69         this.beanName = beanName;
70         this.beanClassName = beanClassName;
71     }
72
73
74     /**
75      * Return the description of the resource that the bean
76      * definition came from.
77      */

78     public String JavaDoc getResourceDescription() {
79         return this.resourceDescription;
80     }
81
82     /**
83      * Return the name of the bean requested.
84      */

85     public String JavaDoc getBeanName() {
86         return this.beanName;
87     }
88
89     /**
90      * Return the name of the class we were trying to load.
91      */

92     public String JavaDoc getBeanClassName() {
93         return this.beanClassName;
94     }
95
96 }
97
Popular Tags