Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Configuring DocumentBuilderFactory to use the system's builder factory

843834Jan 2 2010 — edited Jan 6 2010
Hi,

I wrote a plugin for some application. The plugin uses a DocumentBuilder to read and write XML, so it first calls DocumentBuilderFactory.newInstance() to obtain a factory. As the documentation says, the factory implementation is looked up in various places, in order to enable users to override the factory that is included with the JVM.
It turns out that some other plugins of the application configure the system properties to use their own implementation, so by calling DocumentBuilderFactory.newInstance() I end up with a DocumentBuilder from the other plugins, which happens to be buggy. I would like my plugin to always use the implementation included in the JVM. How do I do this?

(I noticed that DocumentBuilderFactory.newInstance() in my implementation uses "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" as the default factory. Is it the same in all JVMs? If it is, I can simply replace the call to "newInstance" with creating a new instance of this xerces implementation.)

Thanks,
Shlomy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 3 2010
Added on Jan 2 2010
6 comments
1,846 views