title: CXF: java.lang.NoClassDefFoundError: javax/xml/ws/BindingProvider
body: <p>I'm trying to implement Apache CXF in CQ. I've generated proxy classes from WSDL using cxf-codegen-plugin. Now my <code>CxfServiceImpl.java</code> looks like below - </p>
  
  <pre><code>import net.webservicex.ConvertTemperatureSoap;
  import net.webservicex.TemperatureUnit;
  import org.apache.felix.scr.annotations.Activate;
  import org.apache.felix.scr.annotations.Component;
  import org.apache.felix.scr.annotations.Service;
  import org.osgi.framework.BundleContext;
  import org.osgi.service.component.ComponentContext;
  
  @Component(label = "CXF Service", immediate = true, metatype = true)
  @Service(CxfService.class)
  public class CxfServiceImpl implements CxfService {
      private ConvertTemperatureSoap convertTemperatureSoap;
      @Override
      public double convertCelsiusToFahrenheit(double valueToConvert) {
          return convertTemperatureSoap.convertTemp(
          valueToConvert, 
          TemperatureUnit.DEGREE_CELSIUS, 
          TemperatureUnit.DEGREE_FAHRENHEIT);
      }
      @Activate
      protected final void activate(final ComponentContext context) {
          convertTemperatureSoap =
          JaxWsClientFactory.create(
          ConvertTemperatureSoap.class,
          "http://www.w3schools.com/webservices/tempconvert.asmx");    
      }    
  }
  </code></pre>
  
  <p><code>JaxWsClientFactory.java</code> looks like - </p>
  
  <pre><code>import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
  import org.apache.cxf.BusFactory;
  public class JaxWsClientFactory {
      public static &lt;T&gt; T create(Class&lt;T&gt; clazz, String portUrl) {
          ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
          try {
              Thread.currentThread().setContextClassLoader(BusFactory.class.getClassLoader());
              JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
              factory.setServiceClass(clazz);
              factory.setAddress(portUrl);
              return (T) factory.create();
          } finally {
              Thread.currentThread().setContextClassLoader(oldClassLoader);
          }
      }
  }
  </code></pre>
  
  <p>I am able to create OSGI bundle and uploaded in Felix console. But when I try to activate bundle then I get error as below and bundle status is showing as Active. </p>
  
  <pre><code>24.02.2014 20:38:41.104 *ERROR* [127.0.0.1 [1393254521079] POST /system/console/bundles/300 HTTP/1.1] com.adobe.cq.customer-bundle [com.adobe.cq.CxfServiceImpl] The activate method has thrown an exception (java.lang.NoClassDefFoundError: javax/xml/ws/BindingProvider) java.lang.NoClassDefFoundError: javax/xml/ws/BindingProvider
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClassCond(Unknown Source)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2167)
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1471)
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1882)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at com.adobe.cq.JaxWsClientFactory.create(JaxWsClientFactory.java:12)
      at com.adobe.cq.CxfServiceImpl.activate(CxfServiceImpl.java:28)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:236)
      at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)
      at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:613)
      at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:496)
      at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:149)
      at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementationObject(ImmediateComponentManager.java:251)
      at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(ImmediateComponentManager.java:119)
      at org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(AbstractComponentManager.java:1518)
      at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:550)
      at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:261)
      at org.apache.felix.scr.impl.config.ImmediateComponentHolder.enableComponents(ImmediateComponentHolder.java:328)
      at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:158)
      at org.apache.felix.scr.impl.BundleComponentActivator.&lt;init&gt;(BundleComponentActivator.java:113)
      at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:261)
      at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:179)
      at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:868)
      at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:789)
      at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:514)
      at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4319)
      at org.apache.felix.framework.Felix.startBundle(Felix.java:1993)
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:947)
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:934)
      at org.apache.felix.webconsole.internal.core.BundlesServlet.doPost(BundlesServlet.java:339)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:493)
      at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:418)
      at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
      at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
      at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
      at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
      at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
      at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:127)
      at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
      at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
      at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
      at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
      at com.adobe.granite.license.impl.LicenseCheckFilter.doFilter(LicenseCheckFilter.java:179)
      at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
      at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
      at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
      at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
      at org.apache.felix.http.sslfilter.internal.SslFilter.doFilter(SslFilter.java:55)
      at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
      at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
      at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
      at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
      at org.apache.sling.security.impl.ReferrerFilter.doFilter(ReferrerFilter.java:259)
      at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
      at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
      at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
      at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
      at org.apache.sling.engine.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:75)
      at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
      at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
      at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
  
  Caused by: java.lang.ClassNotFoundException: javax.xml.ws.BindingProvider not found by com.adobe.cq.customer-bundle [300]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1499)
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1882)
      at java.lang.ClassLoader.loadClass(Unknown Source) 
  </code></pre>
  
  <p>pom.xml- </p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
      &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
      &lt;extensions&gt;true&lt;/extensions&gt;
      &lt;configuration&gt;
          &lt;instructions&gt;
              &lt;Bundle-SymbolicName&gt;com.adobe.cq.customer-bundle&lt;/Bundle-SymbolicName&gt;
              &lt;Export-Package&gt;
                  com.adobe.cq.*;version=${project.version}
                  javax.xml.ws*;version=2.1;-split-package:=merge-first;-noimport:=true
              &lt;/Export-Package&gt;
              &lt;Private-Package&gt;
                  javax.jws,
                  javax.jws.*,
                  javax.wsdl,
                  org.xml.*,
                  org.apache.cxf,
                  org.apache.cxf.*,
                  javax.xml,
                  org.apache.servicemix.specs.locator;-split-package:=merge-first
                  javax.xml.transform.stax,
                  javax.net.ssl,
                  org.w3c.dom,
                  org.apache.ws.commons.schema.resolver.*,
                  org.apache.ws.commons.schema.extensions.*,
                  org.apache.ws.commons.schema.*,
                  net.webservicex
              &lt;/Private-Package&gt;
              &lt;Include-Resource&gt;{maven-resources}&lt;/Include-Resource&gt;
              &lt;Embed-Dependency&gt;*;scope=compile|runtime;inline=false&lt;/Embed-Dependency&gt;
              &lt;Embed-Transitive&gt;true&lt;/Embed-Transitive&gt;
  
              &lt;Import-Package&gt;
                  org.osgi.framework,
                  org.osgi.service.component.*,
                  com.sun.msv.*;resolution:=optional,
                  com.sun.xml.bind.marshaller.*;resolution:=optional,
                  com.sun.xml.fastinfoset.stax.*;resolution:=optional,
                  net.sf.cglib.*;resolution:=optional,
                  org.apache.aries.*;resolution:=optional,
                  org.apache.axiom.*;resolution:=optional,
                  org.apache.mina.*;resolution:=optional,
                  org.apache.log4j.spi.*;resolution:=optional,
                  org.apache.velocity.*;resolution:=optional,
                  org.osgi.service.blueprint.*;resolution:=optional,
                  org.junit.*;resolution:=optional,
                  org.relaxng.*;resolution:=optional,
                  org.slf4j.spi.*;resolution:=optional,
                  org.springframework.*;resolution:=optional,
                  javax.resource.*;resolution:=optional,
                  javax.mail.*;resolution:=optional,
                  javax.xml.ws.spi.http.*;resolution:=optional,
                  junit.framework.*;resolution:=optional,
                  com.sun.*;resolution:=optional,
                  sun.*;resolution:=optional,
                  org.apache.*;resolution:=optional,
                  org.jvnet.*;resolution:=optional,
                  javax.net.*,
                  javax.xml.transform.stax,
                  !*
              &lt;/Import-Package&gt;
          &lt;/instructions&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>