Hi Isaac,

I suspect there's more going on in your application than what you've shown
in this snippet of code. Are you accessing the same DOM instance from
multiple threads? Xerces DOM is not thread-safe [1] and if you access it
from multiple threads without the appropriate synchronization locks in your
code you can get exceptions such as this one as well as other strange
behaviour.

Thanks.

[1] http://xerces.apache.org/xerces2-j/faq-dom.html#faq-1

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Isaac Ríder Jiménez <[EMAIL PROTECTED]> wrote on 11/19/2008 06:20:49
AM:

> Hi to all
>
> I'm using WebSphere 6.1 (that already includes the Xerces library
> XML4J version 4.4.12)
>
> We have recently had a problem using the class org.apache.xerces.
> dom.DeepNodeListImpl. This is the stack trace:
>
>
>
> 0000002c SystemErr     R java.lang.NullPointerException
> 0000002c SystemErr     R  at org.apache.xerces.dom.DeepNodeListImpl.
> nextMatchingElementAfter(Unknown Source)
> 0000002c SystemErr     R  at org.apache.xerces.dom.DeepNodeListImpl.
> item(Unknown Source)
> 0000002c SystemErr     R  at org.apache.xerces.dom.DeepNodeListImpl.
> getLength(Unknown Source)
>
> We have parsed a XML obtained from a file, and we try to access to a
> element of that XML to take its value:
>
>
>
> // We open a file
>
> InputStream is = new FileInputStream(fileName);
>
> Reader input = new BufferedReader(new InputStreamReader(is))
>
> // parses the file
>
> DOMParser parser = new DOMParser();
> parser.parse(new InputSource(input));
> org.w3c.dom.Document doc = parser.getDocument();
>
> org.w3c.dom.Element e = doc.getDocumentElement()
>
> // Look out for a element in the XML
>
> NodeList nl = e.getElementsByTagName(<some_string>);

> if (nl == null || nl.getLength() < 1)
>
>
>
> as you can see the NodeList is not null. The NodeList object is a
> DeepNodeListImpl object initialized.
>
> When it goes to get the length of the NodeList element it throws a
> NullPointerException, as the stack trace shows.
>
>
>
> We really don't know why this exception has occurred. Any help?.
>
> This problem happens in a PRODUCTION environment and we don't know
> if is a specific one or it will happen always.
>
>
>
> Lot of thanks in advance

Reply via email to