0

I posted a question here and now I have a new problem.
I have updated the IP-address to 10.0.2.2:8080...., rest everything is the same(Gradle dependencies,etc.).
Request doesn't get sent to the web-service and Jersey throws in some kind of warning.
This is the stacktrace:

W/Errors: The following warnings have been detected: WARNING: HK2 service reification failed for [org.glassfish.jersey.message.internal.DataSourceProvider] with an exception: MultiException stack 1 of 4 java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: javax.activation.DataSource at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(LRUHybridCache.java:315) at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl.getAllMethods(ClassReflectionHelperImpl.java:108) at org.jvnet.hk2.internal.Utilities.findInitializerMethods(Utilities.java:1341) at org.jvnet.hk2.internal.DefaultClassAnalyzer.getInitializerMethods(DefaultClassAnalyzer.java:107) at org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getInitializerMethods(JerseyClassAnalyzer.java:242) at org.jvnet.hk2.internal.Utilities.getInitMethods(Utilities.java:218) at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:145) at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:180) at org.jvnet.hk2.internal.SystemDescriptor.internalReify(SystemDescriptor.java:740) at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:694) at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:461) at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2288) at org.jvnet.hk2.internal.ServiceLocatorImpl.access$1200(ServiceLocatorImpl.java:125) at org.jvnet.hk2.internal.ServiceLocatorImpl$9.compute(ServiceLocatorImpl.java:1373) at org.jvnet.hk2.internal.ServiceLocatorImpl$9.compute(ServiceLocatorImpl.java:1368) at org.glassfish.hk2.utilities.cache.internal.WeakCARCacheImpl.compute(WeakCARCacheImpl.java:116) at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetAllServiceHandles(ServiceLocatorImpl.java:1430) at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1355) at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1344) at org.glassfish.jersey.internal.inject.Providers.getServiceHandles(Providers.java:354) at org.glassfish.jersey.internal.inject.Providers.getCustomProviders(Providers.java:201) at org.glassfish.jersey.message.internal.MessageBodyFactory.(MessageBodyFactory.java:221) at java.lang.reflect.Constructor.newInstance(Native Method) at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375) at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:272) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:366) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:83) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:71) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154) at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199) at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:122) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2022) at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:774) at org.jvnet.hk2.internal.ServiceLocatorImpl.getUnqualifiedService(ServiceLocatorImpl.java:786) at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:111) at org.glassfish.jersey.client.RequestProcessingInitializationStage.apply(RequestProcessingInitializationStage.java:97) at org.glassfish.jersey.client.RequestProcessingInitializationStage.apply(RequestProcessingInitializationStage.java:67) at org.glassfish.jersey.process.internal.Stages$LinkedStage.apply(Stages.java:308) at org.glassfish.jersey.process.internal.Stages.process(Stages.java:171) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:25

Edit:
I followed a blog and implemented their way, my warning disappeared but my client still isn't communicating with the server. Also, how does this affect my situation:

I/art: Rejecting re-init on previously-failed class java.lang.Class<org.glassfish.jersey.internal.OsgiRegistry> 

Does the Jersey client work well with Android? If yes, then can appropriate learning materials be provided?

Edit2
I followed this solution and thereby ditched Jersey for good. Jersey seems to be having some bugs with Android(I am just speculating. I cannot confirm for sure).

Shankha057
  • 1,072
  • 14
  • 30
  • clean, and rebuild the project, and check the permission of internet in the Manifest, that's is general steps to do. \n but i recommend you to use this library to fetch data REST, HTTP, JSON https://github.com/amitshekhariitbhu/Fast-Android-Networking it's really simple – Mohamed chiheb Ben jemaa Feb 06 '18 at 11:48
  • @medbenjemaa Tried cleaning and rebuilding. Didn't work. I want to use Jersey of this(I could have used Apache HTTP Client but didn't). My web-service also uses Jersey. – Shankha057 Feb 06 '18 at 12:06
  • you are not required to use Jersey client, there are so much Libraries and frameworks recommended in android, – Mohamed chiheb Ben jemaa Feb 06 '18 at 12:40
  • Using a Jersey over some college student's part time project is preferable. I know Jersey will have continued support. How about the other one? Will the person keep up the support for the library from time to time? – Shankha057 Feb 06 '18 at 12:42
  • of course, you can join the Issues on GitHub, and you can submit your own issue at any time – Mohamed chiheb Ben jemaa Feb 06 '18 at 12:46
  • But is it as reliable as an enterprise managed API like Jersey or Apache Http Client? – Shankha057 Feb 06 '18 at 13:32

1 Answers1

0

Try to add the dependency explicitly:

                <dependencies>
                    <dependency>
                        <groupId>javax.activation</groupId>
                        <artifactId>activation</artifactId>
                        <version>1.1.1</version>
                    </dependency>
                </dependencies>

Source: GitHub issue

Benoit
  • 4,340
  • 2
  • 16
  • 36
  • I do not want to deal with `AsyncTask` as the request takes some time to process and the response code is obtained around 3-4 secs later which is of importance to me. I understand your point. But when I use `ExecutorService.execute()`, the application simply stops and does nothing with this `W/Error` in the console. – Shankha057 Feb 06 '18 at 11:59
  • If the user changes the screen orientation or closes the app while the request is sent, AsyncTask will create problems. – Shankha057 Feb 06 '18 at 12:01
  • And that is why I use `ExecutorServices` as recommended by instructors in the Android dev course in Udacity. – Shankha057 Feb 06 '18 at 12:03
  • @ShankhadeepGhoshal you are right, ma answer is partial and only explains the NetworkOnMainThreadException exception – Benoit Feb 06 '18 at 12:05
  • Well, `ExecutorService` takes care of the additional threading stuff. AsyncTask is some kind of an implementation of `ForkJoinThreadPool` which is an implementation of `ThreadPoolExecutor` which in turn is a type of `ExecutorService. So, my threading needs are taken care of. I suspect that I am having problems with the dependency of Jersey. – Shankha057 Feb 06 '18 at 12:11
  • Look at the updated answer, seem to be a problem related to Java 9 – Benoit Feb 06 '18 at 12:20
  • I am using java 8 – Shankha057 Feb 06 '18 at 12:27
  • And after you add `javax.activation` dependency, they will now ask you for `java.awt.image.` – Shankha057 Feb 06 '18 at 12:38