[ https://issues.apache.org/jira/browse/CXF-4686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13526453#comment-13526453 ]
Sergey Beryozkin commented on CXF-4686: --------------------------------------- Do you have ServiceMix jsr311-api-1.1.1 spec installed ? Needed for CXF 2.6.x to work > NoClassDefFoundError for javax.ws.rs.core.MediaType in OSGi environment > ----------------------------------------------------------------------- > > Key: CXF-4686 > URL: https://issues.apache.org/jira/browse/CXF-4686 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 2.6.2 > Environment: Apache Felix > Reporter: Konrad Windszus > > I try to create a JAX-RS client from bundle a with the help of an annotated > class like > {code} > // Jax-RS client > ProductClientProxy productProxy = JAXRSClientFactory.create(<url>, > ProductClientProxy.class); > {code} > CXF and JAX-RS are both exposed from another bundle (bundle b). The problem > is during runtime I get the following exception > {noformat} > java.lang.NoClassDefFoundError: javax.ws.rs.core.MediaType not found by > <bundle a> [368] > at $Proxy205.<clinit>(Unknown Source) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) > at java.lang.reflect.Constructor.newInstance(Constructor.java:513) > at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:588) > at > org.apache.cxf.common.util.ProxyHelper.getProxyInternal(ProxyHelper.java:45) > at org.apache.cxf.common.util.ProxyHelper.getProxy(ProxyHelper.java:50) > at > org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWithValues(JAXRSClientFactoryBean.java:302) > at > org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.create(JAXRSClientFactoryBean.java:243) > at > org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory.java:86) > at > org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory.java:72) > at > org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory.java:49) > at <code line listed above> > {noformat} > The problem is that CXF tries to instanciate a Client in > JAXRSClientFactoryBean (line 302, leveraging the classloader of the client > bundle (bundle a), not with the classloader of the CXF bundle(bundle b)). > Unfortunately the classloader of the bundle a does not import the package > javax.ws.rs.core, and therefore this NoClassDefFoundError is thrown. > As a workaround we explicitly import the package javax.ws.rs.core in bundle > a. Although I don't know how to fix it from your site, it would be great if > the necessary packages would automatically detected (in this case by the > maven-bundle-plugin) or you use another classloader to load the > org.apache.cxf.jaxrs.client.Client interface, or you remove all the > dependencies on other packages from the Client interface. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira