Does the jersey client support Android?

I want to use REST Jersey Client to call web services. But it doesn't work when called from an Android app; the same web service call works when called from a simple java client (without any Android code). Does this mean that the "Jersey Client" does not work when called in an Android context or does it need some specific configuration for the REST call?

My pom.xml has the following:

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.13</version>
</dependency>

      

My example code:

  Response getResponse = ClientBuilder.newClient()
              .target("http://myserver:8081").path("/users/employees")
              .request()
              .get();

      

I see these ERRORS in the Android emulator logs:

Failed resolving Lorg/glassfish/jersey/internal/OsgiRegistry; interface 2690 'Lorg/osgi/framework/SynchronousBundleListener;'
Link of class 'Lorg/glassfish/jersey/internal/OsgiRegistry;' failed
VFY: unable to find class referenced in signature (Lorg/glassfish/jersey/internal/OsgiRegistry;)
...
Cannot find default implementation of the HK2 ServiceLocatorGenerator
java.lang.ClassNotFoundException: Provider of org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.IllegalStateException: No generator was provided and there is no default generator registered.

      

A related comment here : "Android has a Dalvik virtual machine, not the original JVM. I think the reason the Jersey Client API doesn't work on Android OS, but I know it really is!"

+3


source to share


1 answer


This post is related:

When using jersey for nice api in android app I get this error:

It looks like jersey client is not supported in android: I tried to import a working jersey client for the REST api program in android and got a fatal exception.



12-16 16:41:33.049    3711-3711/com.program.example E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.program.example, PID: 3711
java.lang.VerifyError: com/sun/jersey/core/impl/provider/entity/MimeMultipartProvider
        at java.lang.Class.getDeclaredConstructors(Native Method)
        at java.lang.Class.getConstructors(Class.java:508)
        at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:174)
        at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:166)
        at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
        at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
        at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
        at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
        at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
        at com.sun.jersey.api.client.Client.init(Client.java:342)
        at com.sun.jersey.api.client.Client.access$000(Client.java:118)
        at com.sun.jersey.api.client.Client$1.f(Client.java:191)
        at com.sun.jersey.api.client.Client$1.f(Client.java:187)
        at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
        at com.sun.jersey.api.client.Client.<init>(Client.java:187)
        at com.sun.jersey.api.client.Client.<init>(Client.java:159)
        at com.sun.jersey.api.client.Client.create(Client.java:669)
        at android.view.View.performClick(View.java)
        at android.view.View$PerformClick.run(View.java)
        at android.os.Handler.handleCallback(Handler.java)
        at android.os.Handler.dispatchMessage(Handler.java)
        at android.os.Looper.loop(Looper.java)
        at android.app.ActivityThread.main(ActivityThread.java:5476)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
        at dalvik.system.NativeStart.main(Native Method)

      

I wish I could make a comment ...

0


source







All Articles