JDK-6354969 : Bug in XPathFactory.newInstance() method
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,windows_xp
  • CPU: x86
  • Submitted: 2005-11-23
  • Updated: 2012-06-09
  • Resolved: 2006-12-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
1.4.0 1.4Fixed 6u18Fixed 7Fixed
Related Reports
Duplicate :  
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 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.
11-03-2008

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

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.
10-12-2005