You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Isaac Ríder Jiménez <ji...@hotmail.com> on 2008/11/19 12:20:49 UTC
Problem with XERCES in WebSphere 6.1
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.NullPointerException0000002c 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 fileInputStream is = new FileInputStream(fileName);Reader input = new BufferedReader(new InputStreamReader(is))// parses the fileDOMParser 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 XMLNodeList 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
_________________________________________________________________
Diviértete y aprende con el juego de palabras del Abecedario
http://www.vivelive.com/abecedario/
Re: Problem with XERCES in WebSphere 6.1
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
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: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Isaac Ríder Jiménez <ji...@hotmail.com> 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