Re: [Resteasy-users] RESTEasy Client in OSGi Environment
I think I can confirm that this is the problem. We ran into this same issue when using the RE client in Fuse (also an OSGi environment). It is not possible to export META-INF/* resources in an OSGi bundle. This makes java ServiceLoader useless as a dynamic service discovery mechanism. As a workaround we had to add the RE client's Providers spec file to our own WAR: https://github.com/Governance/s-ramp/tree/master/s-ramp-ui/s-ramp-ui-war-fuse61/src/main/resources/META-INF/services It's not ideal, but it's the only way we could get it working without modifying RE to support OSGi. For the record, the latter wouldn't be too hard - but would likely require that RE look for providers in both META-INF/services/javax.ws.rs.ext.Providers as well as the OSGi Service Registry. -Eric On 5/23/2014 10:57 AM, Bill Burke wrote: I know nothing about OSGi. My guess is that Resteasy automatic provider lookup is not working. The way it works is that it does a Classloader.getResources(META-INF/javax.ws.rs.ext.Providers) and iterates througha nd loads all those files. Those files contain Java class names which represent the providers. On 5/23/2014 9:26 AM, Rohrberg, Timo wrote: Hello everybody, I am currently trying to use the RESTEasy client framework within an OSGi environment (Eclipse Equinox). To provide the required dependencies, I created a separate Eclipse Plug-In containing the required JAR libraries and exporting the contained packages to downstream bundles. Then, I am using the RESTEasy client framework as follows within my main bundle which includes the before mentioned bundle as required bundle: ResteasyClient client = *new*ResteasyClientBuilder().build(); ResteasyWebTarget target = client .target( _http://192.168.100.181:5952/RXT_RESTWebService-2.1/jobtemplates/Vitaphone 300 BT/386340_); RxtDevice device = target.request().get( RxtDevice.*class*); System./out/.println( device.getId() ); Unfortunately, I always get the following error: _javax.ws.rs.client.ResponseProcessingException_: _javax.ws.rs.ProcessingException_: Unable to find a MessageBodyReader of content-type application/xml and type class com.vitasystems.remosxt.rest.client.model.RxtDevice at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(_ClientInvocation.java:140_) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(_ClientInvocation.java:444_) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.get(_ClientInvocationBuilder.java:165_) at de.vitasystems.example.resteasy.client.Activator.start(_Activator.java:25_) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(_BundleContextImpl.java:711_) at java.security.AccessController.doPrivileged(_Native Method_) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(_BundleContextImpl.java:702_) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(_BundleContextImpl.java:683_) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(_BundleHost.java:381_) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(_AbstractBundle.java:390_) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(_Framework.java:1176_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(_StartLevelManager.java:559_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(_StartLevelManager.java:544_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(_StartLevelManager.java:457_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(_StartLevelManager.java:243_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(_StartLevelManager.java:438_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(_StartLevelManager.java:1_) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(_EventManager.java:230_) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(_EventManager.java:340_) Caused by: _javax.ws.rs.ProcessingException_: Unable to find a MessageBodyReader of content-type application/xml and type class com.vitasystems.remosxt.rest.client.model.RxtDevice at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(_ClientReaderInterceptorContext.java:39_) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(_AbstractReaderInterceptorContext.java:73_) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(_AbstractReaderInterceptorContext.java:50_) at
Re: [Resteasy-users] RESTEasy Client in OSGi Environment
I know nothing about OSGi. My guess is that Resteasy automatic provider lookup is not working. The way it works is that it does a Classloader.getResources(META-INF/javax.ws.rs.ext.Providers) and iterates througha nd loads all those files. Those files contain Java class names which represent the providers. On 5/23/2014 9:26 AM, Rohrberg, Timo wrote: Hello everybody, I am currently trying to use the RESTEasy client framework within an OSGi environment (Eclipse Equinox). To provide the required dependencies, I created a separate Eclipse Plug-In containing the required JAR libraries and exporting the contained packages to downstream bundles. Then, I am using the RESTEasy client framework as follows within my main bundle which includes the before mentioned bundle as required bundle: ResteasyClient client = *new*ResteasyClientBuilder().build(); ResteasyWebTarget target = client .target( _http://192.168.100.181:5952/RXT_RESTWebService-2.1/jobtemplates/Vitaphone 300 BT/386340_); RxtDevice device = target.request().get( RxtDevice.*class*); System./out/.println( device.getId() ); Unfortunately, I always get the following error: _javax.ws.rs.client.ResponseProcessingException_: _javax.ws.rs.ProcessingException_: Unable to find a MessageBodyReader of content-type application/xml and type class com.vitasystems.remosxt.rest.client.model.RxtDevice at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(_ClientInvocation.java:140_) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(_ClientInvocation.java:444_) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.get(_ClientInvocationBuilder.java:165_) at de.vitasystems.example.resteasy.client.Activator.start(_Activator.java:25_) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(_BundleContextImpl.java:711_) at java.security.AccessController.doPrivileged(_Native Method_) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(_BundleContextImpl.java:702_) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(_BundleContextImpl.java:683_) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(_BundleHost.java:381_) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(_AbstractBundle.java:390_) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(_Framework.java:1176_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(_StartLevelManager.java:559_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(_StartLevelManager.java:544_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(_StartLevelManager.java:457_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(_StartLevelManager.java:243_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(_StartLevelManager.java:438_) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(_StartLevelManager.java:1_) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(_EventManager.java:230_) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(_EventManager.java:340_) Caused by: _javax.ws.rs.ProcessingException_: Unable to find a MessageBodyReader of content-type application/xml and type class com.vitasystems.remosxt.rest.client.model.RxtDevice at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(_ClientReaderInterceptorContext.java:39_) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(_AbstractReaderInterceptorContext.java:73_) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(_AbstractReaderInterceptorContext.java:50_) at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(_GZIPDecodingInterceptor.java:59_) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(_AbstractReaderInterceptorContext.java:53_) at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(_ClientResponse.java:245_) at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(_ClientResponse.java:179_) at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(_BuiltResponse.java:211_) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(_ClientInvocation.java:104_) ... 18 more By debugging the included libraries, I tracked the problem down to the following location: ResteasyProviderFactory.java *protected*T MessageBodyReaderT resolveMessageBodyReader(ClassT type, Type genericType, Annotation[] annotations, MediaType mediaType,