JAX-WS = When Apache CXF is installed it “steals” default JDK JAX-WS implementation, how to solve?

后端 未结 5 1286
轮回少年
轮回少年 2020-11-28 03:15

I have a strange problem.

  1. Using wsimport I generated als JAX-WS Code from a WSDL (in a dedicated eclipse java project). This works fine in JDK6 without any

5条回答
  •  天命终不由人
    2020-11-28 03:39

    Apache CXF (cxf-rt-frontend-jaxws-*.jar to be precise) registers itself as a JAX-WS provider in the JVM. Inside the aforementioned JAR there is a file named: /META-INF/services/javax.xml.ws.spi.Provider with the following contents:

    org.apache.cxf.jaxws.spi.ProviderImpl
    

    If you now look at javax.xml.ws.spi.FactoryFinder#find method you will discover that JDK searches the CLASSPATH for the presence of javax.xml.ws.spi.Provider file and falls back to default Sun implementation if not available. So you have two options to force fallback:

    • either remove cxf-rt-frontend-jaxws-*.jar from CLASSPATH

    • or override javax.xml.ws.spi.Provider file provided by CXF to point to fallback location

    The second option is actually a bit easier. Simply create:

    /src/main/resources/META-INF/services/javax.xml.ws.spi.Provider
    

    file (assuming you are using Maven) with the following contents:

    org.apache.cxf.jaxws.spi.ProviderImpl
    

    That's it, tested with javax.xml.ws.Endpoint#publish.

提交回复
热议问题