We too faced similar problem in OSGi. Setting system property javax.ws.rs.ext.RuntimeDelegate=org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl, issue is resolved.
Regards Raman -----Original Message----- From: Pitteloud, Gaëtan [mailto:[email protected]] Sent: Friday, November 09, 2012 7:14 PM To: [email protected] Subject: OSGi : fails to load CXF classes Hi all, I must use CXF (client) within a RCP (eclipse) application. Here's my config: - I have defined a plugin project that contains a library with the code that makes the CXF call (actually uses WebClient). This bundle A imports org.apache.cxf.bundle-minimal (Require-bundle) and specifies the library in the Classpath header of the MANIFEST. - My OSGi runtime contains servicemix's jsr311 bundle, and this bundle is the only provider of javax.ws.rs.* - I'm using Gemini blueprint to expose the service defined in the library of bundle A - Bundle B (ui bundle) imports service defined in bundle A, also using Gemini blueprint facilities. - When invoking the service from B, it tries to create a WebClient to issue a http request, and I get the following error: Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:122) at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:91) at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:69) at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:80) at org.apache.cxf.jaxrs.client.LocalClientState.<init>(LocalClientState.java:47) at org.apache.cxf.jaxrs.client.AbstractClient.<init>(AbstractClient.java:96) at org.apache.cxf.jaxrs.client.WebClient.<init>(WebClient.java:76) at org.apache.cxf.jaxrs.client.WebClient.<init>(WebClient.java:72) at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:197) at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:206) at org.apache.cxf.jaxrs.client.WebClient.create(WebClient.java:142) at org.apache.cxf.jaxrs.client.WebClient.create(WebClient.java:115) ... 43 more Caused by: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass(ContextFinder.java:131) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:37) at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:143) at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:105) ... 54 more Based on what I know from FactoryFinder, it tries to load a file named META-INF/services/javax.ws.rs.ext.RuntimeDelegate, that contains the implementation class name of the RuntimeDelegate to use. If either the file or the class defined in the file cannot be loaded, it tries to load the default RuntimeDelegate implementation, which is com.sun.ws.rs.ext.RuntimeDelegateImpl. Thus getting this exception. org.apache.cxf.bundle-minimal contains a file named META-INF/services/javax.ws.rs.ext.RuntimeDelegate, and this file contains a class name that exists in cxf bundle, thus I rather suspect some classloading issues related to bundles since CXF and servicemix jsr311 are in separate bundles. Did anybody already face such an issue ? Thanks in advance, -- Gaëtan
