如何在 Glassfish 上选择 CXF 而不是 Metro
我在运行我的程序时遇到以下问题(由其他人报告) Glassfish 下的企业应用程序。在 Jetty 下工作正常。
javax/xml/ws/spi/Provider 提到创建 META-INF/services/javax.xml.ws.spi.Provider 资源,但是 CXF 已经提供了该资源,并且创建额外的资源文件并不能解决 Glassfish 下的此问题。
有谁知道如何确保 CXF 在 GlassFish 下被拾取?
(我正在使用具有 CXF 依赖项 2.2.5 的 Maven 多模块项目)
谢谢!
Tim
编辑 #1
现在跳过这个问题,只使用 Metro,但我真的很想知道如何使用 CXF(如果有人有任何指示的话)。如果没有任何效果,我可能不得不切换Web 应用程序容器(或查看 Metro 来满足我的要求)
编辑 #2
一些解决方案通过添加
到 sun-web.xml 文件。但是,这不适用于非战争应用程序。
I'm having the following problem (reported there by someone else) when running my enterprise application under Glassfish. Under Jetty it works fine.
javax/xml/ws/spi/Provider mentions creating a META-INF/services/javax.xml.ws.spi.Provider resource, but this is already supplied with CXF and creating an additional resource file does not solve this problem under Glassfish.
Does anyone know how to ensure that CXF is picked up under GlassFish?
(I'm using a Maven Multi-modules project with CXF dependency 2.2.5)
Thanks!
Tim
EDIT #1
Skipping the problem for now and just working with Metro, but I'd really like to know how to use CXF instead if anyone has any pointers.. If nothing works I might have to switch web application container (or look into Metro to fill my requirements)
EDIT #2
Some of the solutions detail the fix for war's by adding <class-loader delegate="false"/>
to the sun-web.xml file. However, this does not work for non-war ee apps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
添加 sun-web.xml 并将 delegate=false 设置为类加载器:
Add a sun-web.xml and set delegate=false to the class-loader:
Metro(Glassfish 的 JAX-WS 实现)jar 可能包含在 Glassfish 中,您可以将它们从类路径中排除吗?由于您使用的是 Maven,因此您应该分析 glassfish 依赖项并使用 Metro jar 的排除项。
看来您需要在 Metro jar 之前将 CXF jar 放在应用程序类路径上。您可能无法修改系统类加载器/类路径,但可以更改 Thread.currentThread().getContextClassLoader() 以便它首先加载 CXF。您还可以修改 Glassfish 中的类路径设置
查看
javax.xml.ws.spi.FactoryFinder#find
() 查看提供程序实际是如何加载的The Metro (Glassfish's JAX-WS implementation) jars are probably being included with Glassfish, can you exclude them from the classpath? Since you're using maven, you should analyze the glassfish dependencies and using an exclusion for the metro jars.
It seems that you need to have the CXF jars on the applications classpath before the Metro jars. You probably can't modify the system classloader/classpath but you can change the
Thread.currentThread().getContextClassLoader()
such that it loads CXF first. There also might a classpath settings in Glassfish you can modifyCheck out the source for
javax.xml.ws.spi.FactoryFinder#find
() to see how the provider is actually loaded我想出的(并且不满意的)解决方案是使用 JaxWsProxyFactoryBean。 此处有一个示例。
这是你必须做的事情的要点:
The solution I came up with (and am unsatisfied with) is to use
JaxWsProxyFactoryBean
. There is an example here.This is the jist of what you have to do:
对于 SpringBoot 应用程序,我需要添加以下文件:
src/main/resources/META-INF/services/javax.xml.ws.spi.Provider
,内容为:
org.apache.cxf。 jaxws.spi.ProviderImpl
For SpringBoot application I needed to add following file:
src/main/resources/META-INF/services/javax.xml.ws.spi.Provider
with content:
org.apache.cxf.jaxws.spi.ProviderImpl