Hi,
I am using the rxFlowable extensions to execute GraphQL operations and get RxJava observables with the following code.
// Subscription
ApolloCall<MySubscription.Data> subscriptionCall = client.subscription(new MySubscription());
Flowable<ApolloResponse<MySubscription.Data>> subscriptionResponse = Rx2Apollo.flowable(subscriptionCall);
subscriptionResponse.subscribe(this.onMessageHandler, this.onErrorHandler);
But when I tried to call subscriptionResponse.subscribe(this.onMessageHandler, this.onErrorHandler) it failed and getting the following error.
Exception in thread “pool-7-thread-1” java.lang.NoClassDefFoundError: Could not initialize class com.apollographql.apollo3.api.json.BufferedSourceJsonReader
at com.apollographql.apollo3.network.ws.WsProtocol.toMessageMap(WsProtocol.kt:101)
at com.apollographql.apollo3.network.ws.WsProtocol.receiveMessageMap(WsProtocol.kt:131)
at com.apollographql.apollo3.network.ws.WsProtocol$receiveMessageMap$1.invokeSuspend(WsProtocol.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@45425b78, java.util.concurrent.Executors$FinalizableDelegatedExecutorService@2beb7c92]
Any idea with the above error that I am facing ?
Note: The version that I tried 3.3.0 and 3.6.2, none of them working.
Hi!
The NoClassDefFoundError
hints at a classpath problem or an issue while trying to initialize the BufferedSourceJsonReader
class.
Could you share how you have setup your project? BufferedSourceJsonReader
is part of apollo-api
, which is a dependency of apollo-runtime
.
Also did you see any other exceptions in the logs prior to this one?
Hi, the project that I am running is Helidon with dependency of apollo-rx3-support and apollo-runtime-jvm through the maven. You may refer to this
graphql-subscription
But now I got different error message instead.
Exception in thread “pool-3-thread-1” java.lang.NoSuchFieldError: Companion
at com.apollographql.apollo3.api.json.BufferedSourceJsonReader.(BufferedSourceJsonReader.kt:950)
at com.apollographql.apollo3.network.ws.WsProtocol.toMessageMap(WsProtocol.kt:101)
at com.apollographql.apollo3.network.ws.WsProtocol.receiveMessageMap(WsProtocol.kt:131)
at com.apollographql.apollo3.network.ws.WsProtocol$receiveMessageMap$1.invokeSuspend(WsProtocol.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@5c421b78, java.util.concurrent.Executors$FinalizableDelegatedExecutorService@135200dd]
After analyzed the first subscription failure I am getting this error
Exception in thread “pool-3-thread-1” java.lang.NoSuchFieldError: Companion
at com.apollographql.apollo3.api.json.BufferedSourceJsonReader.(BufferedSourceJsonReader.kt:950)
at com.apollographql.apollo3.network.ws.WsProtocol.toMessageMap(WsProtocol.kt:101)
at com.apollographql.apollo3.network.ws.WsProtocol.receiveMessageMap(WsProtocol.kt:131)
at com.apollographql.apollo3.network.ws.WsProtocol$receiveMessageMap$1.invokeSuspend(WsProtocol.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@387e1a38, java.util.concurrent.Executors$FinalizableDelegatedExecutorService@66468c29]
and the subsequent failure subscription returned the following error message.
Exception in thread “pool-5-thread-1” java.lang.NoClassDefFoundError: Could not initialize class com.apollographql.apollo3.api.json.BufferedSourceJsonReader
at com.apollographql.apollo3.network.ws.WsProtocol.toMessageMap(WsProtocol.kt:101)
at com.apollographql.apollo3.network.ws.WsProtocol.receiveMessageMap(WsProtocol.kt:131)
at com.apollographql.apollo3.network.ws.WsProtocol$receiveMessageMap$1.invokeSuspend(WsProtocol.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@11eec94a, java.util.concurrent.Executors$FinalizableDelegatedExecutorService@32929e2]
Hi, I think I found the root cause, missing the apollo-api dependency. And i fixed it with adding this in pom.
I have no idea why it work in Springboot without this dependency but not Helidon.
Anyway thanks for the clue.
Thanks for the follow-up!
We’ve had issues with people using Maven in the past too (most people using the library use it with Gradle).
I’m glad you found a fix!
@ASoftwareProgramer Thanks for raising this concern. I was curious, what does your application do exactly? Are you using Java for Mobile Android development, or is this something else all together? Any additional information would help us tremendously to better understand your use case here. Thank you!