问题
For some reason we need the xdb.jar from the Oracle XDK. This jar depends on the xmlparserv2.jar. The actual problem is that the xmlparserv2.jar comes with some provider-configuration files (META-INF/services). The jar has Services Providers for javax.xml.transform.TransformerFactory, javax.xml.parsers.SAXParserFactory and javax.xml.parsers.DocumentBuilderFactory. The implementations (from oracle.*) don't work together with some other parts of our software (they need the standard factories).
回答1:
You could use separate classloaders to isolate the jars from the rest of the application. This question about covers it.
回答2:
You could just remove these classes from the xmlparserv2.jar
回答3:
See here - "JNLP classpath precedence 1.5 vs 1.6"
回答4:
I solved the problem by removing the services (META-INF/services). We ran our unit tests and everything worked. Even the parts of our software which are depending on xmlparserv2.jar/xdb.jar.
来源:https://stackoverflow.com/questions/6412736/how-can-i-tell-my-application-that-it-shouldnt-use-an-external-service-provider