How to correctly change javax.xml.ws.spi.Provider?
jokser Jan 23, 2015 5:48 AMHi, everyone!
Recently I started to learn Switchyard 2.0 (on Wildfly 8.1) and I needed to configure JAX-WS client (Proxy, SSL, SOAP Interceptors etc.). I found that since version 2.0 of Switchyard I can use cxf.xml descriptor for it. I found how to enable Apache CXF (with Spring) in my applications. But there was one sad fact - Spring Bus for CXF was created once, cached cxf.xml config (from one of deployed applications, which deployed first) and it was static for all applications and never changes. So I couldn't deploy two or more applications with different cxf.xml and for every change in my cxf configration I had to restart server.
But I solved this problem. After some debugging I explored that Wildfly uses pure Apache CXF JAX-WS provider as JAX-WS provider instead of JbossWS wrap for it, where enabled bus selection strategies and bus creates for each deployed app. I found that provider class for JAX-WS is readed from META-INF/services/javax.xml.ws.spi.Provider file. I found several places for this file:
1) org.apache.cxf.impl module - cxf-rt-frontend-jaxws.jar
2) org.jboss.ws.cxf.jbossws-cxf-factories module.
3) and I also created this file in my application jar.
Wildfly reads this file from cxf-rt-frontend-jaxws.jar and I can't force him to read this file from my jar or from org.jboss.ws.cxf.jbossws-cxf-factories. I solved it dirty - just unpack cxf-rt-frontend-jaxws.jar, change provider to org.jboss.wsf.stack.cxf.client.ProviderImpl and repack back.
But I'm sure there is more beatiful solution. Maybe I need to add/change some additional options in jboss-deployment-structure.xml? I really don't clearly understand imports/exports directives for modules. Please help me to solve this problem correctly. I would be glad for any advices and explanations.
Here it's my jboss-deployment-structure.xml:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <dependencies> <module name="org.jboss.ws.cxf.jbossws-cxf-client" services="import" /> <module name="org.apache.cxf.impl" export="true"> <imports> <include path="META-INF" /> <include path="META-INF/cxf" /> <include path="META-INF/services" /> </imports> <exports> <include path="META-INF" /> <include path="META-INF/cxf" /> <include path="META-INF/services" /> </exports> </module> <module name="org.apache.cxf" export="true"> <imports> <include path="META-INF" /> <include path="META-INF/cxf" /> <include path="META-INF/services" /> </imports> <exports> <include path="META-INF" /> <include path="META-INF/cxf" /> <include path="META-INF/services" /> </exports> </module> <module name="org.springframework.spring"> <imports> <include path="META-INF" /> </imports> <exports> <include path="META-INF" /> </exports> </module> </dependencies> </deployment> </jboss-deployment-structure>