I ran into the same issue last year, we had a pretty healthy discussion about it here http://mail-archives.apache.org/mod_mbox/xerces-j-users/201106.mbox/browser
Just a few synchronized(){} blocks around the DOM API and everything is fine. No easily noticeable drop in performance, though I haven't yet measured, and if I did it would probably be noticeable. I think most people still agree there should be a thread safe implementation of the parser, but the authors of xerces were pretty clear that it isn't going to happen... -----Original Message----- From: karthikeyan...@polarisft.com [mailto:karthikeyan...@polarisft.com] Sent: Friday, October 12, 2012 07:51 To: j-users@xerces.apache.org; j-users-i...@xerces.apache.org; j-...@xerces.apache.org Subject: Why DOM Parser is not thread safe? Please explain Apache Team, Major concern for us with DOM parser in multi thread environment. Can you please review this and provide your inputs? Thanks. OS: Sun Solaris 10 Server: Websphere 6 JDK: 1.4 Xerces version: Xerces_Version_1_2_0 Number of Daemon threads per JVM: 3 Scenario: In our Production environment when 3 daemon threads run under a JVM. When 3 similar type of XML messages gets parsed at same second (concurrently) under a JVM, we notice some attribute gets missed. We went through net and found that DOM implementation is not guaranteed to be thread safe. But question is why it is not thread safe? Which part can go wrong? Please provide details. Below is the piece of code: public Document parse(InputSource inputSource, boolean isValidating) throws SAXException,IOException { if ( getEntityResolver() == null ) throw new IllegalStateException("EnitityResolver is not set"); DocumentBuilder docBuilder = getDocumentBuilder(isValidating); // parsing from input source docBuilder.setEntityResolver(getEntityResolver()); docBuilder.setErrorHandler (getErrorHandler()); return docBuilder.parse(inputSource); } Sample xml passed to this code is attached: sample_message.xml (See attached file: sample_message.xml) Thanks, karthik This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.com --------------------------------------------------------------------- To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org For additional commands, e-mail: j-users-h...@xerces.apache.org