依赖于不同 Xalan 实现的两个程序如何在同一个 VM/系统类加载器中共存?
我在几个口味,我想我没有问正确的问题。我现在怀疑 Xalan,因为它正在实现 Java 认可的标准,所以在给定的 VM / ClassLoader 上只能有一种实现。
那么这是真的吗?两个 Xalan 实现不能“存在”在同一个系统类加载器中吗?或者如果可以的话,如何?
I asked this question in several flavors, and I think I'm not asking the right question. I'm suspecting now that Xalan, since it's implementing a Java endorsed standard, can only have one implementation at a given VM / ClassLoader.
So is it true? can't 2 Xalan implementaions "live" in the same System ClassLoader? Or if they can, How?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这似乎是一个令人惊讶的答案:
对于每个 Xalan 实现,使用单独的类加载器,并在
META-INF\services\
中添加一个名为“编辑它”的文件,并将其作为类加载器将只包含在 Xalan 实现中的内容使用,例如:
注意:这里的好处是,与常规类加载委托相反,
META-INF\services
正在被搜索在当前的类加载器中首先,其中类在父类中搜索,然后是系统,然后才在子类加载器中搜索This seems to be the surprising answer:
For each Xalan implementation use a seperate classloader, and add a file in
META-INF\services\
calledEdit it and put it's only content the Xalan implementation the class loader will use, e.g.:
NOTE: The nice thing here is that as opposed to the regular class loading delegation,
META-INF\services
is being searched in the current class loader first, where as classes are being search in the parent, then system, and only then in the child classloderjdk中包含一些xalan版本。对于大多数用途,我个人的经验是使用这个版本就足够了。即使可能是以前的版本,现在xalan有新的开发吗?我更喜欢使用附带的、经过严格测试的版本。
我不认为必须在同一个 jdk 中使用 xsl 变压器是一个好主意(即使我猜这是可以做到的)。如果您确实需要使用 xalan 的某些更新版本,而不是 jdk 版本,您可以参考此常见问题解答:http://xml.apache.org/xalan-j/faq.html#faq-N100EF
我剥离了大型应用程序中所有特定的 xalan 依赖项,仅使用嵌入式的。作为 FOP 的库,尽管它们之前假装需要一些特定的 xalan jar,但没有它也可以正常运行,并且它解决了许多类加载问题(java ee 应用服务器在打包 xalan 时在某些情况下出现问题)。
There is some xalan version included in the jdk. For most usages, my personal experience is that using this version is enough. Even if it could be a previous version, is there any new xalan development nowadays? I prefer using the included, strongly tested version.
I don't think having to xsl transformers in the same jdk is a good idea (even if I guess it can be done). If you really need to use some updated version of xalan, instead of the jdk one, you could referer to this faq: http://xml.apache.org/xalan-j/faq.html#faq-N100EF
I stripped all specific xalan dependencies in big applications, using just the embedded one. Libraries as FOP, although they previously pretended to require some specific xalan jar, ran just fine without it, and it solved a lot of class loading issues (java ee app server giving problems in some situations when xalan was packaged).