OK, kinda makes sense with the deferred document model but what about the
non-deferred model? Is there any thread-safe way to *read* a DOM from
multiple threads simultaneously?

Regards,
Peter Smith

> -----Original Message-----
> From: Michael Glavassevich [mailto:[EMAIL PROTECTED]
> Sent: 28 October 2003 14:35
> To: '[EMAIL PROTECTED]'
> Subject: Re: multi-threaded issues on a multi-cpu machine
> 
> 
> Hello Peter,
> 
> The reason why you're getting all of these exceptions is that Xerces'
> DOM implementation is not thread safe [1]. Since there's no 
> requirement
> that a DOM be thread safe, you need to make sure that your threads are
> properly synchronized for concurrent access to the DOM. This 
> is true even
> if you're just reading the tree. Xerces has a deferred DOM 
> implementation
> (the one that you're seeing exceptions with), which defers 
> construction of
> nodes until they're actually read. It's a form of lazy initialization
> which can perform very well when the user doesn't read the 
> entire tree,
> but it also means that a side-effect of reading the tree is that the
> structure may be mutated.
> 
> [1] http://xml.apache.org/xerces2-j/faq-dom.html#faq-1
> 
> On Tue, 28 Oct 2003, Smith, Peter (ELSLON) wrote:
> 
> > Hi,
> >
> > I have a web application that caches DOMs (for site 
> navigation, page layout
> > etc..) internally.
> >
> > I am having problems with exceptions being thrown from within
> > org.apache.xerces.dom.DeferredDocumentImpl when reading the 
> DOMs (eg. in a
> > xpath operation, when applying a stylesheet)
> >
> > Some examples of the exceptions that are being thrown:
> > - synchronizeData() : NullPointerException
> > - getNodeObject() : java.lang.IllegalArgumentException: type: -1
> > - getNodeValueString() -> java.util.Vector.elementAt():
> > java.lang.ArrayIndexOutOfBoundsException: 4 >= 0
> >
> > These exceptions only occur when running the application on 
> a multi-cpu
> > machine.
> >
> > Has anyone seen problems like this before?
> >
> > Using xerces-2.5.0.
> >
> > Regards,
> > Peter Smith
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: [EMAIL PROTECTED]
> E-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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

Reply via email to