title: How do I stop cxf trying to take over the default implementation of javax.xml.ws.spi.Provider?
body: <p>Karaf 2.3.2 </p>
  
  <p>As far as I am aware, I have no references to Apache cxf in my code or container configuration, however when I try to consume Exchange webservices, the jax implementation is being taken over by cxf giving this error as I don't have cxf installed: </p>
  
  <p>./data/karaf.out:javax.xml.ws.spi.FactoryFinder$ConfigurationError: Provider org.apache.cxf.jaxws.spi.ProviderImpl not found </p>
  
  <p>I have created the file META-INF\services\javax.xml.ws.spi.Provider with the contents com.sun.xml.internal.ws.spi.ProviderImpl, however in Karaf this doesn't appear to register. </p>
  
  <p>Any thoughts as to why it is trying to load cxf despite no references to cxf? Or is there another way to force the use of the default implementation? </p>
  
  <p>Many thanks </p>
  
  <p>For ref, the provider.provide() method which appears to be attempting to load the cxf implementation </p>
  
  <pre><code>/** 
   * 
   * Creates a new provider object. 
   * &lt;p&gt;
   * The algorithm used to locate the provider subclass to use consists 
   * of the following steps: 
   * &lt;p&gt;
   * &lt;ul&gt;
   * &lt;li&gt;
   *   If a resource with the name of 
   *   &lt;code&gt;META-INF/services/javax.xml.ws.spi.Provider&lt;/code&gt;
   *   exists, then its first line, if present, is used as the UTF-8 encoded 
   *   name of the implementation class. 
   * &lt;/li&gt;
   * &lt;li&gt;
   *   If the $java.home/lib/jaxws.properties file exists and it is readable by 
   *   the &lt;code&gt;java.util.Properties.load(InputStream)&lt;/code&gt; method and it contains 
   *   an entry whose key is &lt;code&gt;javax.xml.ws.spi.Provider&lt;/code&gt;, then the value of 
   *   that entry is used as the name of the implementation class. 
   * &lt;/li&gt;
   * &lt;li&gt;
   *   If a system property with the name &lt;code&gt;javax.xml.ws.spi.Provider&lt;/code&gt;
   *   is defined, then its value is used as the name of the implementation class. 
   * &lt;/li&gt;
   * &lt;li&gt;
   *   Finally, a default implementation class name is used. 
   * &lt;/li&gt;
   * &lt;/ul&gt;
   * 
   */ 
  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); 
      } 
  } 
  </code></pre>