关于weblogic中使用Dom4j、Xerces导致执行线程挂起的问题
2009-09-22 00:00:00 来源:WEB开发网其实在上面的分析中可以看到,前三项中都没有找到parser factory, 那我们只能在当前class loader中去查找,并创建instance。因为你的应用部署在weblogic上, weblogic的classloader机制是,所有的应用class loader都继承于weblogic application class loader, 所以你会看到weblogic class loader在trace中。但为什么不停的在class loader呢?其实看看JDK文档,并看看JDK的实现就能知道,
protected Class<?> loadClass(String name,
boolean resolve)
throws ClassNotFoundException
Loads the class with the specified binary name. The default implementation of this method searches for classes in the following order:
Invoke findLoadedClass(String) to check if the class has already been loaded.
Invoke the loadClass method on the parent class loader. If the parent is null the class loader built-in to the virtual machine is used, instead.
Invoke the findClass(String) method to find the class.
If the class was found using the above steps, and the resolve flag is true, this method will then invoke the resolveClass(Class) method on the resulting Class object.
1 protected synchronized Class loadClass(String name, boolean resolve)
2 throws ClassNotFoundException
3 {
4 // First, check if the class has already been loaded
5 Class c = findLoadedClass(name);
6 if (c == null) {
7 try {
8 if (parent != null) {
9 c = parent.loadClass(name, false);
10 } else {
11 c = findBootstrapClass0(name);
12 }
13 } catch (ClassNotFoundException e) {
14 // If still not found, then invoke findClass in order
15 // to find the class.
16 c = findClass(name);
17 }
18 }
19 if (resolve) {
20 resolveClass(c);
21 }
22 return c;
23 }
看看,其实能看到loadclass(),并不能说class loader一定在load class,更多的时候,他们是在find loaded class,否则怎么去创建对象?
更多精彩
赞助商链接