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> MessageBodyReader<T> resolveMessageBodyReader(Class<T>
> type, Type genericType, Annotation[] annotations, MediaType mediaType,
> MediaTypeMap<SortedKey<MessageBodyReader>> availableReaders)
>
> {
>
> List<SortedKey<MessageBodyReader>> readers =
> availableReaders.getPossible(mediaType, type);
>
> //logger.info("******** getMessageBodyReader *******");
>
> *for*(SortedKey<MessageBodyReader> reader : readers)
>
> {
>
> //logger.info("     matching reader: " + reader.getClass().getName());
>
> *if*(reader.obj.isReadable(type, genericType, annotations, mediaType))
>
> {
>
> *return*(MessageBodyReader<T>) reader.obj;
>
> }
>
> }
>
> *return**null*;
>
> }
>
> The problem is a little weired: The readers list of MessageBodyReader
> instances contains the
> org.jboss.resteasy.plugins.providers.jaxb.JAXBXmlRootElementProvider,
> but the reader.obj.isReadable() method returns false for that reader.
>
> In another setup as a plain Maven project outside of the OSGi world, the
> the referred method reader.obj.isReadable() returns true and the same
> piece of code works.
>
> I am at the end of my knowledge… Do you guys have any hints?
>
> Best regards,
>
> Timo Rohrberg
>
>
> ------------------------------------------------------------------------
> Hinweis: Diese Email enthält evtl. vertrauliche und rechtlich geschützte
> Informationen. Sollten Sie nicht der richtige Adressat sein oder diese
> Email irrtümlich erhalten haben, informieren Sie bitte sofort den Absender,
> und löschen Sie anschließend diese E-Mail. Das unerlaubte Kopieren sowie
> die unbefugte Weitergabe des Inhalts dieser Email sind nicht gestattet.
>
> Attention: This e-mail may contain confidential and/or privileged
> information. If you are not the intended recipient or if you have received
> this e-mail in error, please notify the sender immediately and delete this
> e-mail. Any unauthorized copying, disclosure or distribution of the
> contents of this e-mail is strictly prohibited.
>
>
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
>
>
>
> _______________________________________________
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to