xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: AbstractDOMParser.setDocumentClassName() and classloaders
Date Wed, 18 Apr 2007 05:55:43 GMT
At 06:40 PM 4/15/2007, you wrote:
 >Hi Jake,
 >
 >Jacob Kjome <hoju@visi.com> wrote on 04/15/2007 07:08:01 PM:
 >
 >> I've got a parser extending DOMParser and call
 >> parser.setDocumentClassName(MetaDataDocument.class.getName()) .
 >
 >This method gets called during reset. Your own code probably shouldn't be
 >calling it. Setting the "document-class-name" property [1] is the
 >supported way to override the default Document implementation.
 >

You're right.  And I was confused.  It was setting this value on my 
own wrapper class for DOMParser, which then sets the property the 
appropriate way.


 >> The problem is, the class MetaDataDocument is in a child classloader and
 >
 >> Xerces reports that it can't find it.....
 >>
 >>       [xmlc] Error: java.lang.IllegalArgumentException:
 >> MissingDocumentClassName:
 >>   The class name of the document factory
 >> "org.enhydra.xml.xmlc.metadata.MetaDataDocument" used to construct
 >> the DOM tree could not be found.
 >>       [xmlc] java.lang.IllegalArgumentException:
 >> MissingDocumentClassName: The class name of the document factory
 >> "org.enhydra.xml.xmlc.metadata.MetaDataDocument" used to construct
 >> the DOM tree could not be found.
 >>
 >> As you may recognize, this is in the context of an Ant
 >> task.  Specifically, the XMLC Ant task.  Ant includes XercesImpl.jar
 >> in ANT_HOME/lib.  My library is added to the taskdef via a
 >> <classpath> element.  I know Xerces runs through some fancy routines
 >> to find classloaders, but it doesn't seem to be doing the job
 >> here.  I'm wondering if you have any suggestions to resolve this issue?
 >
 >Is the child ClassLoader which knows how to load MetaDataDocument the
 >current thread's context ClassLoader? That's where Xerces looks.
 >

Thanks for the hint.  I resolved this by resetting the context class 
loader to the one that loaded the Ant task and setting it back again 
in a "finally" block before leaving the method.


Jake

 >
 >[1]
 >http://xerces.apache.org/xerces2-j/properties.html#dom.document-class-name
 >
 >Michael Glavassevich
 >XML Parser Development
 >IBM Toronto Lab
 >E-mail: mrglavas@ca.ibm.com
 >E-mail: mrglavas@apache.org



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


Mime
View raw message