-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b142
-
x86
-
linux
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2179414 | 6-pool | Unassigned | P3 | Closed | Future Project | |
JDK-2179415 | 5.0-pool | Unassigned | P4 | Closed | Won't Fix | |
JDK-2207373 | 1.4.0 | Joe Wang | P3 | Closed | Fixed | 1.4 |
For background, see:
http://www.netbeans.org/nonav/issues/show_bug.cgi?id=139048
To reproduce, run the following with Apache Xerces in the classpath:
---%<---
import java.net.URL;
import java.net.URLClassLoader;
import javax.xml.parsers.SAXParserFactory;
public class TestJAXP {
public static void main(String[] args) throws Exception {
Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader().getParent()));
SAXParserFactory.newInstance();
}
}
---%<---
Under JDK 6 I get:
Exception in thread "main" javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:134)
at TestJAXP.main(TestJAXP.java:7)
The reason is that FactoryFinder.findJarServiceProvider behaves as follows:
1. Check the thread's CCL for META-INF/services/javax.xml.parsers.SAXParserFactory. This is not found, since the CCL does not see the app class loader.
2. is == null, so set cl = null (bootstrap loader), and call SecuritySupport.getResourceAsStream.
3. ClassLoader.getSystemResourceAsStream(...) returns the resources from xerces.jar, because it checks the app class loader, not the bootstrap loader (which has no such resource).
4. newInstance(null, "org.apache.xerces....", false) is called, which asks for org.apache.xerces... from the CCL, which cannot see it.
http://www.netbeans.org/nonav/issues/show_bug.cgi?id=139048
To reproduce, run the following with Apache Xerces in the classpath:
---%<---
import java.net.URL;
import java.net.URLClassLoader;
import javax.xml.parsers.SAXParserFactory;
public class TestJAXP {
public static void main(String[] args) throws Exception {
Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader().getParent()));
SAXParserFactory.newInstance();
}
}
---%<---
Under JDK 6 I get:
Exception in thread "main" javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:134)
at TestJAXP.main(TestJAXP.java:7)
The reason is that FactoryFinder.findJarServiceProvider behaves as follows:
1. Check the thread's CCL for META-INF/services/javax.xml.parsers.SAXParserFactory. This is not found, since the CCL does not see the app class loader.
2. is == null, so set cl = null (bootstrap loader), and call SecuritySupport.getResourceAsStream.
3. ClassLoader.getSystemResourceAsStream(...) returns the resources from xerces.jar, because it checks the app class loader, not the bootstrap loader (which has no such resource).
4. newInstance(null, "org.apache.xerces....", false) is called, which asks for org.apache.xerces... from the CCL, which cannot see it.
- backported by
-
JDK-2179414 Confusion between bootstrap and system class loaders in FactoryFinder.findJarServiceProvider
-
- Closed
-
-
JDK-2207373 Confusion between bootstrap and system class loaders in FactoryFinder.findJarServiceProvider
-
- Closed
-
-
JDK-2179415 Confusion between bootstrap and system class loaders in FactoryFinder.findJarServiceProvider
-
- Closed
-
- relates to
-
JDK-6865375 (cl) Request ClassLoader.getResourcePairs(String) => Enumeration<(ClassLoader,URL)>
-
- Open
-