You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2010/02/08 14:04:28 UTC

[jira] Issue Comment Edited: (XERCESJ-1419) Classloadering strategy for javax.xml.datatype.FactoryFinder is not consistent with javax.xml.parsers.DocumentBuilderFactory

    [ https://issues.apache.org/jira/browse/XERCESJ-1419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12830929#action_12830929 ] 

Michael Glavassevich edited comment on XERCESJ-1419 at 2/8/10 1:04 PM:
-----------------------------------------------------------------------

XML Commons is a separate project from Xerces-J. Issues for it are tracked in ASF Bugzilla [1] (instead of JIRA). Please open your bug report there.

[1] https://issues.apache.org/bugzilla/

      was (Author: mrglavas@ca.ibm.com):
    XML Commons is a different project than Xerces-J. Issues for it are tracked in ASF Bugzilla [1] (instead of JIRA). Please open your bug report there.

[1] https://issues.apache.org/bugzilla/
  
> Classloadering strategy for javax.xml.datatype.FactoryFinder is not consistent with javax.xml.parsers.DocumentBuilderFactory
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1419
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1419
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.datatype)
>    Affects Versions: 2.9.1
>            Reporter: Andy Piper
>            Priority: Minor
>
> javax.xml.parsers.DocumentBuilderFactory looks first at the ContextClassLoader then Class.forName, but FactoryFinder does not. This causes problems on OSGi systems and it seems that the two strategies should be consistent. Here is the patch I used.
> Eagle Andy> diff -rc tmp/javax xml-commons-external-1.4.01/javax
> diff -rc tmp/javax/xml/datatype/FactoryFinder.java xml-commons-external-1.4.01/j
> avax/xml/datatype/FactoryFinder.java
> *** tmp/javax/xml/datatype/FactoryFinder.java   2009-02-16 00:09:32.000000000 +0
> 000
> --- xml-commons-external-1.4.01/javax/xml/datatype/FactoryFinder.java   2010-01-
> 19 11:03:01.070864200 +0000
> ***************
> *** 143,164 ****
>        */
>       static Object newInstance(
>         String className,
> !         ClassLoader classLoader)
>           throws ConfigurationError {
> !
>           try {
> !             Class spiClass;
> !             if (classLoader == null) {
> !                 spiClass = Class.forName(className);
>               } else {
> !                 spiClass = classLoader.loadClass(className);
> !             }
> !
> !             if (debug) {
> !               debugPrintln("Loaded " + className + " from " + which(spiClass))
> ;
>               }
> !
> !             return spiClass.newInstance();
>           } catch (ClassNotFoundException x) {
>               throw new ConfigurationError(
>                   "Provider " + className + " not found", x);
> --- 145,179 ----
>        */
>       static Object newInstance(
>         String className,
> !         ClassLoader cl)
>           throws ConfigurationError {
> !
>           try {
> !             Class providerClass;
> !             if (cl == null) {
> !                 // If classloader is null Use the bootstrap ClassLoader.
> !                 // Thus Class.forName(String) will use the current
> !                 // ClassLoader which will be the bootstrap ClassLoader.
> !                 providerClass = Class.forName(className);
>               } else {
> !                 try {
> !                     providerClass = cl.loadClass(className);
> !                 } catch (ClassNotFoundException x) {
> !                         // Fall back to current classloader
> !                         cl = FactoryFinder.class.getClassLoader();
> !                         if (cl != null) {
> !                             providerClass = cl.loadClass(className);
> !                         }
> !                         else {
> !                             providerClass = Class.forName(className);
> !                         }
> !                 }
>               }
> !
> !             Object instance = providerClass.newInstance();
> !             if (debug) debugPrintln("created new instance of " + providerClass
>  +
> !                    " using ClassLoader: " + cl);
> !             return instance;
>           } catch (ClassNotFoundException x) {
>               throw new ConfigurationError(
>                   "Provider " + className + " not found", x);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org