I want to use REST Jersey Client to invoke web services. But it is failing when invoked from android app; the same web service call works when invoked from simple java client (without any Android code). Does it mean Jersey Client doesn't work when invoked in Android's context or it needs any specific configuration to make a REST call?
My pom.xml has this:
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.13</version>
</dependency>
My sample code:
Response getResponse = ClientBuilder.newClient()
.target("http://myserver:8081").path("/users/employees")
.request()
.get();
I see these ERRORS in 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.
Related comment here: "Android has Dalvik Virtual Machine, not original JVM. I think this the reason why Jersey Client API does not work in Android OS. but I'am nog sure!"