graphql-kotlin icon indicating copy to clipboard operation
graphql-kotlin copied to clipboard

Compatibility with Ktor 3.x.x seems to break again starting from 8.6.0

Open AngeloFilaseta opened this issue 7 months ago • 3 comments

Library Version

  • com.expediagroup:graphql-kotlin-ktor-server >= 8.6.0
  • Ktor 3.x.x

Describe the bug The bug is almost identical to #2069; Most of the Ktor classes fail to resolve at runtime. The library expect to find the API of Ktor 2.x.x

Stacktrace example:

Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/server/routing/RoutingKt
        at com.expediagroup.graphql.server.ktor.GraphQLRoutesKt.graphQLPostRoute(GraphQLRoutes.kt:65)
        at com.expediagroup.graphql.server.ktor.GraphQLRoutesKt.graphQLPostRoute$default(GraphQLRoutes.kt:64)
        at com.example.MainKt.module$lambda$2(Main.kt:30)
        at io.ktor.server.routing.RoutingRoot$Plugin.install(RoutingRoot.kt:153)
        at io.ktor.server.routing.RoutingRoot$Plugin.install(RoutingRoot.kt:133)
        at io.ktor.server.application.ApplicationPluginKt.install(ApplicationPlugin.kt:121)
        at io.ktor.server.routing.RoutingRootKt.routing(RoutingRoot.kt:181)
        at com.example.MainKt.module(Main.kt:29)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:569)
        at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97)
        at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Static.call(CallerImpl.kt:106)
        at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:207)
        at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:112)
        at io.ktor.server.engine.internal.CallableUtilsKt.callFunctionWithInjection(CallableUtils.kt:127)
        at io.ktor.server.engine.internal.CallableUtilsKt.executeModuleFunction(CallableUtils.kt:40)
        at io.ktor.server.engine.EmbeddedServer.launchModuleByName$lambda$32(EmbeddedServerJvm.kt:422)
        at io.ktor.server.engine.EmbeddedServer.avoidingDoubleStartupFor(EmbeddedServerJvm.kt:446)
        at io.ktor.server.engine.EmbeddedServer.launchModuleByName(EmbeddedServerJvm.kt:421)
        at io.ktor.server.engine.EmbeddedServer.dynamicModule$lambda$26(EmbeddedServerJvm.kt:381)
        at io.ktor.server.engine.EmbeddedServer.instantiateAndConfigureApplication$lambda$25(EmbeddedServerJvm.kt:371)
        at io.ktor.server.engine.EmbeddedServer.avoidingDoubleStartup(EmbeddedServerJvm.kt:428)
        at io.ktor.server.engine.EmbeddedServer.instantiateAndConfigureApplication(EmbeddedServerJvm.kt:370)
        at io.ktor.server.engine.EmbeddedServer.createApplication(EmbeddedServerJvm.kt:171)
        at io.ktor.server.engine.EmbeddedServer.start(EmbeddedServerJvm.kt:301)
        at io.ktor.server.netty.EngineMain.main(EngineMain.kt:25)
Caused by: java.lang.ClassNotFoundException: io.ktor.server.routing.RoutingKt
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        ... 28 more

To Reproduce I could successfully reproduce the error using the same "Minimum Reproducible Code sample "attached in #2069 changing these versions in the libs.version.toml

ktor-version = "3.1.2"
graphql-version= "8.6.0"

Expected behavior The Library should correctly resolve the classes of Ktor 3.x.x

Additional comment Any version of GraphQL 9.0.0 works as expected. Since version 8.5.0 also works correctly, I would expect subsequent minor releases to work as well. Is this a bug or an intentional design choice? I couldn’t find any clarification in the documentation. Thanks for your work!

AngeloFilaseta avatar May 15 '25 09:05 AngeloFilaseta

Also has this issue: 'java.lang.Object io.ktor.server.request.ApplicationReceiveFunctionsKt.receiveNullable(io.ktor.server.application.ApplicationCall, io.ktor.util.reflect.TypeInfo, kotlin.coroutines.Continuation)' at com.expediagroup.graphql.server.ktor.KtorGraphQLRequestParser.parsePostRequest(KtorGraphQLRequestParser.kt:69) at com.expediagroup.graphql.server.ktor.KtorGraphQLRequestParser.parseRequest$suspendImpl(KtorGraphQLRequestParser.kt:45) at com.expediagroup.graphql.server.ktor.KtorGraphQLRequestParser.parseRequest(KtorGraphQLRequestParser.kt) at com.expediagroup.graphql.server.ktor.KtorGraphQLRequestParser.parseRequest(KtorGraphQLRequestParser.kt:37) at com.expediagroup.graphql.server.execution.GraphQLServer$execute$2.invokeSuspend(GraphQLServer.kt:50) at com.expediagroup.graphql.server.execution.GraphQLServer$execute$2.invoke(GraphQLServer.kt) at com.expediagroup.graphql.server.execution.GraphQLServer$execute$2.invoke(GraphQLServer.kt) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:66)

ktor version 3.1.3 graphql version >=8.6.0

JajaComp avatar May 16 '25 09:05 JajaComp

We have this issue too. Versions 8.5.0 and 8.x.x have diverged since 8.2.1:

% git log -1 $(git merge-base 8.5.0 8.6.0)
commit 2318398c9d9c5321955b8b883c8065f0a911afee (tag: 8.2.1)

Fix of the similar closed issue https://github.com/ExpediaGroup/graphql-kotlin/issues/2069, present in 8.3.0, 8.4.0, 8.5.0 and 9.0.0-alpha.1 onwards, is not in git history of 8.6.0 and 8.7.0

anton-subbotin avatar May 19 '25 11:05 anton-subbotin

Is there an outlook on a fix for this issue? It prevents us from updating to anything higher than 8.5.0.

jurmous avatar Jun 24 '25 11:06 jurmous