如何阻止cxf尝试接管javax.xml.ws.spi.Provider的默认实现?

如何阻止cxf尝试接管javax.xml.ws.spi.Provider的默认实现?,cxf,karaf,Cxf,Karaf,卡拉夫2.3.2 据我所知,我的代码或容器配置中没有对Apache cxf的引用,但是,当我尝试使用Exchange webservices时,jax实现正被cxf接管,导致此错误,因为我没有安装cxf: ./data/karaf.out:javax.xml.ws.spi.FactoryFinder$ConfigurationError:Provider org.apache.cxf.jaxws.spi.ProviderImpl未找到 我已经创建了META-INF\services\javax.

卡拉夫2.3.2

据我所知,我的代码或容器配置中没有对Apache cxf的引用,但是,当我尝试使用Exchange webservices时,jax实现正被cxf接管,导致此错误,因为我没有安装cxf:

./data/karaf.out:javax.xml.ws.spi.FactoryFinder$ConfigurationError:Provider org.apache.cxf.jaxws.spi.ProviderImpl未找到

我已经创建了META-INF\services\javax.xml.ws.spi.Provider文件,其内容为com.sun.xml.internal.ws.spi.ProviderImpl,但是在Karaf中这似乎没有注册

有没有想过为什么它会在没有引用cxf的情况下尝试加载cxf?还是有其他方法强制使用默认实现

非常感谢

对于ref,是provider.provide()方法,该方法似乎正在尝试加载cxf实现

/** 
 * 
 * Creates a new provider object. 
 * <p>
 * The algorithm used to locate the provider subclass to use consists 
 * of the following steps: 
 * <p>
 * <ul>
 * <li>
 *   If a resource with the name of 
 *   <code>META-INF/services/javax.xml.ws.spi.Provider</code>
 *   exists, then its first line, if present, is used as the UTF-8 encoded 
 *   name of the implementation class. 
 * </li>
 * <li>
 *   If the $java.home/lib/jaxws.properties file exists and it is readable by 
 *   the <code>java.util.Properties.load(InputStream)</code> method and it contains 
 *   an entry whose key is <code>javax.xml.ws.spi.Provider</code>, then the value of 
 *   that entry is used as the name of the implementation class. 
 * </li>
 * <li>
 *   If a system property with the name <code>javax.xml.ws.spi.Provider</code>
 *   is defined, then its value is used as the name of the implementation class. 
 * </li>
 * <li>
 *   Finally, a default implementation class name is used. 
 * </li>
 * </ul>
 * 
 */ 
public static Provider provider() { 
    try { 
        Object provider = getProviderUsingServiceLoader(); 
        if (provider == null) { 
            provider = FactoryFinder.find(JAXWSPROVIDER_PROPERTY, DEFAULT_JAXWSPROVIDER); 
        } 
        if (!(provider instanceof Provider)) { 
            Class pClass = Provider.class; 
            String classnameAsResource = pClass.getName().replace('.', '/') + ".class"; 
            ClassLoader loader = pClass.getClassLoader(); 
            if(loader == null) { 
                loader = ClassLoader.getSystemClassLoader(); 
            } 
            URL targetTypeURL  = loader.getResource(classnameAsResource); 
            throw new LinkageError("ClassCastException: attempting to cast" + 
                   provider.getClass().getClassLoader().getResource(classnameAsResource) + 
                   "to" + targetTypeURL.toString() ); 
        } 
        return (Provider) provider; 
    } catch (WebServiceException ex) { 
        throw ex; 
    } catch (Exception ex) { 
        throw new WebServiceException("Unable to createEndpointReference Provider", ex); 
    } 
} 

首先,您不应该安装CXF捆绑包,其次,您需要向系统捆绑包公开“com.sun.xml.internal.ws.spi”包。

事实证明,Karaf包含FactoryFinder.java的和实现,它在lib/approved文件夹中查找CXF实现。 我刚刚删除了这个文件夹