How can I tell my application that it shouldn't use an external Service Provider from a jar?

╄→尐↘猪︶ㄣ 提交于 2019-12-13 17:17:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!