United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6354969 : Bug in XPathFactory.newInstance() method

Details
Type:
Bug
Submit Date:
2005-11-23
Status:
Resolved
Updated Date:
2012-06-09
Project Name:
JDK
Resolved Date:
2006-12-18
Component:
xml
OS:
linux,windows_xp
Sub-Component:
jaxp
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0,6
Fixed Versions:
1.4.0 (1.4)

Related Reports
Backport:
Backport:
Backport:
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
5.0 update 2 and all earlier releases

ADDITIONAL OS VERSION INFORMATION :
All OSes (bug in Java code)

A DESCRIPTION OF THE PROBLEM :
The XPathFactory.newInstance() method never looks for the META-INF/services/javax.xml.xpath.XPathFactory properties file in the Thread's context class loader, but ALWAYS uses the system one. The following patch fixes the problem:

diff -U3 -r src/javax/xml/xpath/SecuritySupport.java srcx/javax/xml/xpath/SecuritySupport.java
--- src/javax/xml/xpath/SecuritySupport.java    Fri Mar  4 00:26:36 2005
+++ srcx/javax/xml/xpath/SecuritySupport.java   Tue Apr 12 23:17:02 2005
@@ -103,7 +103,7 @@
                     if (cl == null) {
                         enumeration = ClassLoader.getSystemResources(name);
                     } else {
-                        enumeration = cl.getSystemResources(name);
+                        enumeration = cl.getResources(name);
                     }
                     return enumeration;
                 }



REPRODUCIBILITY :
This bug can be reproduced often.

CUSTOMER SUBMITTED WORKAROUND :
Apply this patch:

diff -U3 -r src/javax/xml/xpath/SecuritySupport.java srcx/javax/xml/xpath/SecuritySupport.java
--- src/javax/xml/xpath/SecuritySupport.java    Fri Mar  4 00:26:36 2005
+++ srcx/javax/xml/xpath/SecuritySupport.java   Tue Apr 12 23:17:02 2005
@@ -103,7 +103,7 @@
                     if (cl == null) {
                         enumeration = ClassLoader.getSystemResources(name);
                     } else {
-                        enumeration = cl.getSystemResources(name);
+                        enumeration = cl.getResources(name);
                     }
                     return enumeration;
                 }

                                    

Comments
EVALUATION

this change has already been made to the JAXP 1.3.1 & 1.4 code bases.
it needs to be part of a J2SE 5.0, Tiger, update.
                                     
2005-12-10
EVALUATION

as this fix was delivered into Mustang, a subCR was created for possible Tiger update.
                                     
2006-12-18
EVALUATION

It's correct that it's fixed in jaxp on java.net. But it was mistakenly marked as fixed in jdk6. A request to integrate the patch into jdk6 update release was made. I'm also upgrading the priority since this is violation of the specification (refer to javadoc for javax.xml.validation.SchemaFactory.)

The user comment was right that the fix was not in JDK5.0_11. Due to SSR, the fix was moved into JDK5.0_14.
                                     
2008-03-11



Hardware and Software, Engineered to Work Together