DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26613>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26613

AbstractDOMParser setDocumentClassName ClassLoader problem

           Summary: AbstractDOMParser setDocumentClassName ClassLoader
                    problem
           Product: Xerces2-J
           Version: 2.6.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


We are using Websphere 5.0.2, and have deployed a prior version of Xerces (to 
support other 3rd party jars we use)

The problem is manifested as an IllegalArgumentException
with message :
 PAR002 Class, "org.apache.xerces.dom.DocumentImpl", is not of type 
org.w3c.dom.Document.
org.apache.xerces.dom.DocumentImpl

this is thrown from:
org.apache.xerces.parsers.AbstractDOMParser.setDocumentClassName(String)

AbstractDOMParser was loaded by the System ClassLoader

Our investigation reveals that the expression:
Document.class.isAssignableFrom (_class):
evaluates to false because _class represents the 
class 'org.apache.xerces.dom.DocumentImpl' loaded from the context class 
loader, while Document.class is from the same class loader as this.getClass()

this is because a few lines above:
ObjectFactory.findClassLoader()
returns the context class loader


We have a proposed fix (see below) for the immediately obvious problem, which 
will make the code consistent with code in public void startDocument(...) { }, 
but the question of alternate document implementations, and inheritance across 
class loaders has not been addressed.
We would suggest some improvements to the exception handling and messages, so 
that related problems may be more easily diagnosed.

Please feel free to e-mail us at [EMAIL PROTECTED] (or 
[EMAIL PROTECTED]) to discuss further.

--  --  --  --

    protected void setDocumentClassName (String documentClassName) {
        
        // normalize class name
        if (documentClassName == null) {
            documentClassName = DEFAULT_DOCUMENT_CLASS_NAME;
        }
        
        if (!documentClassName.equals(DEFAULT_DOCUMENT_CLASS_NAME)) {
                        // verify that this class exists and is of the right 
type
                        try {
                                Class _class = ObjectFactory.findProviderClass 
(documentClassName,
                                ObjectFactory.findClassLoader (), true);
                                //if (!_class.isAssignableFrom(Document.class)) 
{
                                if (!Document.class.isAssignableFrom (_class)) {
                                        // REVISIT: message
                                        throw new IllegalArgumentException 
("PAR002 Class, \"" +
                                        documentClassName +
                                        "\", is not of type 
org.w3c.dom.Document.\n" +
                                        documentClassName);
                                }
                        }
                        catch (ClassNotFoundException e) {
                                // REVISIT: message
                                throw new IllegalArgumentException ("PAR003 
Class, \"" +
                                documentClassName +
                                "\", not found.\n" +
                                documentClassName);
                        }
                }
        
        // set document class name
        fDocumentClassName = documentClassName;
        if (!documentClassName.equals (DEFAULT_DOCUMENT_CLASS_NAME)) {
            fDeferNodeExpansion = false;
        }
        
    } // setDocumentClassName(String)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to