!--a11y-->
Loading JAXP Implementation 
The JAXP implementation is loaded in the following way:
...
1. searching for a system property
2. if no property is found, then the jaxp.properties file of the JDK is searched
3. searching META-INF/services/javax.xml.XXX resource, where XXX is DocumentBuilderFactoryImpl, SAXParserFactoryImpl, and so on, in the thread context classloader
4. loading the default implementation

Setting system properties in a system that supports more than one parser, is prohibited.
In JAXP 1.1 (or older versions) the class loader from which the implementation is loaded, is obtained through the JAXP interfaces class loader.
Since JAXP 1.1.3 (or newer versions) the implementation is loaded calling the following method: Thread.currentThread().getContextClassloader().One of the reasons for this change is that in JDK 1.4, the JAXP interfaces are loaded by the system class loader. By default this invocation returns the following class loader - sun.misc.Launcher$AppClassloader. Normally this class loader does not have reference to any parser in JDK 1.3.x, so this would result in an exception:
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.crimson.jaxp.DocumentBuilderFactoryImpl not found at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:109)
This is because JAXP has a fallback value for the name of the class that has to be loaded, and this class is included in the JDK 1.4. Since JAXP does not succeed to find the META files in sun.misc.Launcher$AppClassloader class loader , it tries to load the factory from the fallback value, which is not included in JDK 1.3.x. The solution for this problem is simple. Before invoking
DocumentBuilderFactory.newInstance(), you must take care to set the correct class loader, that is, a class loader that has reference to the SAP XML Toolkit for Java, or whatever JAXP implementation you use.
This task can be performed in the following way:
Classloader cl = Thread.currentThread().getContextClassloader();
Thread.currentThread().setContextClassloader(this.getClass().getClassloader());
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); // or // arbitrary code that might need to use JAXP
Thread.currentThread().setContextClassloader(oldLoader);
It is essential that you set back the class loader that originally was set. Some other applications might rely on it. Problems may occur if these applications find a class loader that has the JAXP implementation in it.
