CXF: java.lang.NoClassDefFoundError: javax/xml/ws/BindingProvider | Community
Skip to main content
Level 6
October 16, 2015
Solved

CXF: java.lang.NoClassDefFoundError: javax/xml/ws/BindingProvider

  • October 16, 2015
  • 6 replies
  • 8694 views

Dear experts, 

I'm trying to implement Apache CXF in CQ. I've generated proxy classes from WSDL using cxf-codegen-plugin. Now my CxfServiceImpl.java looks like below - 

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");    }    
}

JaxWsClientFactory.java looks like - 

 

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.BusFactory;
public class JaxWsClientFactory {
    public static <T> T create(Class<T> 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);
        }
    }
}

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. Attached is the pom.xml. Sincerely thanks for your help!

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.<init>(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) 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

I have successfully built Java proxy classes using CFX WSDL to Java and have successfully created an OSGi bundle that works within AEM:

[img]CFXWS.png[/img]

I will write this up as a community article and post the URL from this thread.

Basic steps:

1 - download CXF and create the Java proxy classes:

C:\ApacheCXF\apache-cxf-2.6.0\bin>wsdl2java -p com.aem.ws -d c:\proxyfiles
 http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL

2 - bundle the files (located in c:\proxyfiles -- see -d in previous command) into a JAR (all proxy classes are in a Java package named com.aem.ws -- see -p in the CXF command). 

3 - Use Eclipse to build an OSGi bundle via the plug-in project. Import the JAR that contains the Java web service proxy files.

4 - Deploy the OSGi to AEM. Place into an Active State.  

5- Consume the OSGi from a JSP:
 

<%@include file="/libs/foundation/global.jsp"%>
<h1><%= properties.get("title", currentPage.getTitle()) %></h1>

<h2>Here is an AEM service created from Apache CXF Java proxy classes:</h2>
<%
 
com.aem.ws.Weather weather = new com.aem.ws.Weather(); 

com.aem.ws.WeatherSoap wsaop = weather.getWeatherSoap(); 
 
com.aem.ws.WeatherReturn wr = wsaop.getCityWeatherByZIP("95101");
 

%>
 
<h2>The following describes the weather for 95101 ZIP Code</h2>
<h3><%= "The city is " +wr.getCity()%></h3>
<h3><%= "The state is " +wr.getState()%></h3>
<h3><%= "The description is " +wr.getDescription()%></h3>
<h3><%= "The wind is " +wr.getWind()%></h3>
<h3><%= "The current temp is " +wr.getTemperature()%></h3>
<h3><%= "The current Humidity is " +wr.getRelativeHumidity()%></h3>

 

Also - modify the sling.properties to use web services as discussed in the web service article. See http://helpx.adobe.com/experience-manager/using/creating-cxf-bundles-consume-web.html.

6 replies

smacdonald2008
Level 10
October 16, 2015

Can you try using JAX-WS and follow this web service article. This has been tested numerous times and successfully consumes a 3rd party web service:

http://helpx.adobe.com/experience-manager/using/creating-cq-bundles-consume-web.html

Level 6
October 16, 2015

Thanks Scott for your help as always!

I've already gone through this link but this link does not talk about CXF. I'm looking for CXF implementation. 

smacdonald2008
Level 10
October 16, 2015

Yes - the current way that we have documented CQ and web services is using JAX-WS to generate the Java proxy classes. We successfully got it talking to a 3rd party WSDL:

[img]WSClient.png[/img]

However, what we will do is take this use case, and add it to the community article list. Then we will work through it, and develop a community article with working code. 

In the mean-time - if any other community member has worked with CXF - please let us know what happened.  

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

I have successfully built Java proxy classes using CFX WSDL to Java and have successfully created an OSGi bundle that works within AEM:

[img]CFXWS.png[/img]

I will write this up as a community article and post the URL from this thread.

Basic steps:

1 - download CXF and create the Java proxy classes:

C:\ApacheCXF\apache-cxf-2.6.0\bin>wsdl2java -p com.aem.ws -d c:\proxyfiles
 http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL

2 - bundle the files (located in c:\proxyfiles -- see -d in previous command) into a JAR (all proxy classes are in a Java package named com.aem.ws -- see -p in the CXF command). 

3 - Use Eclipse to build an OSGi bundle via the plug-in project. Import the JAR that contains the Java web service proxy files.

4 - Deploy the OSGi to AEM. Place into an Active State.  

5- Consume the OSGi from a JSP:
 

<%@include file="/libs/foundation/global.jsp"%>
<h1><%= properties.get("title", currentPage.getTitle()) %></h1>

<h2>Here is an AEM service created from Apache CXF Java proxy classes:</h2>
<%
 
com.aem.ws.Weather weather = new com.aem.ws.Weather(); 

com.aem.ws.WeatherSoap wsaop = weather.getWeatherSoap(); 
 
com.aem.ws.WeatherReturn wr = wsaop.getCityWeatherByZIP("95101");
 

%>
 
<h2>The following describes the weather for 95101 ZIP Code</h2>
<h3><%= "The city is " +wr.getCity()%></h3>
<h3><%= "The state is " +wr.getState()%></h3>
<h3><%= "The description is " +wr.getDescription()%></h3>
<h3><%= "The wind is " +wr.getWind()%></h3>
<h3><%= "The current temp is " +wr.getTemperature()%></h3>
<h3><%= "The current Humidity is " +wr.getRelativeHumidity()%></h3>

 

Also - modify the sling.properties to use web services as discussed in the web service article. See http://helpx.adobe.com/experience-manager/using/creating-cxf-bundles-consume-web.html.

Level 2
October 16, 2015

Hi Scott,

Is there any weather information check india zip code "wsf File"

smacdonald2008
Level 10
October 16, 2015

The example web service uses USA zip codes.