0

Karaf 2.3.2

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:

./data/karaf.out:javax.xml.ws.spi.FactoryFinder$ConfigurationError: Provider org.apache.cxf.jaxws.spi.ProviderImpl not found

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.

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?

Many thanks

For ref, the provider.provide() method which appears to be attempting to load the cxf implementation

/** 
 * 
 * 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); 
    } 
} 
user2641043
  • 405
  • 3
  • 12

2 Answers2

0

First you should not install CXF bundles, second, you need to expose the "com.sun.xml.internal.ws.spi" package to the system bundle.

Willem Jiang
  • 3,291
  • 1
  • 14
  • 14
0

It turns out that Karaf includes the and implementation of the FactoryFinder.java where it looks for the cxf implementation in the lib/endorsed folder. I just deleted this folder.

user2641043
  • 405
  • 3
  • 12