Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot use JAXP and JAXB because they are not thread-safe?  RSS feed

 
Dani Mazzuca
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I was participating in meeting about a Web Service project yesterday and I was surprised when I discovered that the architects where planning to use their own in-house Java API instead of using JAXB or JAXP APIs. When I asked why did decide that, the answer was:

�JAXP and JAXB are not thread-safe APIs�

Well, now I am more confused, and I would like to listen to other opinions. I mean, I know that many Java classes are not thread safe (like for example, clases in the Collections API), but, in the case we need to use a class that it is not thread safe in a concurrent environment, we can either control access using synchronization, or in same cases, use different instances in each thread.

I should confess I am not an WebService expert, however, as far as I know, even if many classes in JAXP or JAXB are not thread safe, this is not a valid argument for not using them. Am I right?

Could someone expert in WebService tell me if there is something about thread-safety, JAXB and JAXP that I am missing? I mean, something important than we may consider not using them in a WebService project?

Than you in advance,

DaniMazzuca
[ July 12, 2005: Message edited by: Dani Mazzuca ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I don't think you can use the same DocumentBuilder instance in multiple Threads, but there should be no problem using DocumentBuilderFactory to get an instance for each Thread.
By venturing outside the Java standard libraries and creating their own API, they are just asking for trouble - IMHO. The standard libraries have been tested very thoroughly.
Bill
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This does seem an absurd decision to me too - though my voice won't add much weight behind William's, since I'm significantly less experienced.

Still, your architects are apparently confident that they can produce a better solution than Sun's JAXB programmers (or Apache's...), and that this is a cost-effective means of production. They must be brilliant!

Some obvious Googling found This discussion of JAXB thread safety. These posts relating to JAXP hint at issues involving the same parser/builder in different threads.

Your argument seems solid to me - handling thread safety where necessary by appropriate wrappers/factory methods instantiating new objects is the way to go. Crimson and Xerces are used all over the place...I'd wager your project is not the first to hit multithreading issues with XML libraries


-Tim
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!