关于weblogic中使用Dom4j、Xerces导致执行线程挂起的问题
2009-09-22 00:00:00 来源:WEB开发网我们可以看看SAXParserFactory.newInstance()的实现,
1 public static SAXParserFactory newInstance()
2 throws FactoryConfigurationError
3 {
4 try
5 {
6 return (SAXParserFactory)FactoryFinder.find("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
7 }
8 catch(FactoryFinder.ConfigurationError configurationerror)
9 {
10 throw new FactoryConfigurationError(configurationerror.getException(), configurationerror.getMessage());
11 }
12 }
再来看看FactoryFinder.find()的实现,
1 static Object find(String s, String s1)
2 throws ConfigurationError
3 {
4 debugPrintln("debug is on");
5 ClassLoader classloader = findClassLoader();
6 try
7 {
8 String s2 = System.getProperty(s);
9 if(s2 != null)
10 {
11 debugPrintln("found system property " + s2);
12 return newInstance(s2, classloader);
13 }
14 }
15 catch(SecurityException _ex) { }
16 try
17 {
18 String s3 = System.getProperty("java.home");
19 String s5 = s3 + File.separator + "lib" + File.separator + "jaxp.properties";
20 File file = new File(s5);
21 if(file.exists())
22 {
23 Properties properties = new Properties();
24 properties.load(new FileInputStream(file));
25 String s7 = properties.getProperty(s);
26 debugPrintln("found java.home property " + s7);
27 return newInstance(s7, classloader);
28 }
29 }
30 catch(Exception exception) { }
31 String s4 = "META-INF/services/" + s;
32 try
33 {
34 java.io.InputStream inputstream = null;
35 if(classloader == null)
36 inputstream = ClassLoader.getSystemResourceAsStream(s4);
37 else
38 inputstream = classloader.getResourceAsStream(s4);
39 if(inputstream != null)
40 {
41 debugPrintln("found " + s4);
42 BufferedReader bufferedreader;
43 try
44 {
45 bufferedreader = new BufferedReader(new InputStreamReader(inputstream, "UTF-8"));
46 }
47 catch(UnsupportedEncodingException _ex)
48 {
49 bufferedreader = new BufferedReader(new InputStreamReader(inputstream));
50 }
51 String s6 = bufferedreader.readLine();
52 bufferedreader.close();
53 if(s6 != null && !"".equals(s6))
54 {
55 debugPrintln("loaded from services: " + s6);
56 return newInstance(s6, classloader);
57 }
58 }
59 }
60 catch(Exception exception1) { }
61 if(s1 == null)
62 {
63 throw new ConfigurationError("Provider for " + s + " cannot be found", null);
64 } else
65 {
66 debugPrintln("loaded from fallback value: " + s1);
67 return newInstance(s1, classloader);
68 }
69 }
70
更多精彩
赞助商链接