You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Roytman, Alex" <ro...@peacetech.com> on 2000/11/21 07:15:32 UTC
FW: Creating SAXParser from multiple threads. NULL POINTER EXCEPT
ION
I am forwarding this message to xalan list because I've read you have been
having some threading problems with Xerces
-----Original Message-----
From: Roytman, Alex [mailto:roytmana@peacetech.com]
Sent: Tuesday, November 21, 2000 1:01 AM
To: 'xerces-j-dev@xml.apache.org'
Subject: Creating SAXParser from multiple threads. NULL POINTER
EXCEPTION
I have been having some problems with Xerces 1.2.1 in multithreaded
environment for a while.
So I tried a simple test and it seems to me it shows some problems with
creating SAXParser simultaneously in multiple threads. It blows with
NullPointerException:
java.lang.NullPointerException
at
org.apache.xerces.validators.common.XMLValidator.init(XMLValidator.java:1535
)
at
org.apache.xerces.validators.common.XMLValidator.<init>(XMLValidator.java:40
1)
at org.apache.xerces.framework.XMLParser.<init>(XMLParser.java:203)
at org.apache.xerces.parsers.SAXParser.<init>(SAXParser.java:164)
at pti.gao.gwiz.xmap.dtools.Test$SaxThread.run(Test.java:22)
I only create parser with SAXParser parser = new SAXParser();
I do not even parse - just create.
If I span only one thread everything works fine.
if I put SAXParser parser = new SAXParser(); in synchronized block
everything works fine too.
I do not recall seeing anything about not creating SAXParser with new
SAXParser() but in case I missed it my apologies
here is my simple test program
import org.w3c.dom.Document;
import org.apache.xerces.parsers.SAXParser;
public class Test {
public static final Object syncObj = new Object();
public static void main(String[] args) {
for (int i = 0; i < 3; i++) {
new SaxThread().start();
}
}
public static class SaxThread extends Thread {
public void run() {
for (int i = 0; i < 100; i++) {
try {
SAXParser parser;
//synchronized(syncObj) {
parser = new SAXParser();
//}
} catch (Exception ex) {
ex.printStackTrace();
}
}
System.out.println("\nDONE " + this);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org