hey, when I post request to the backend, I got an ...
# ktor
k
hey, when I post request to the backend, I got an error that
Copy code
2025-01-04 21:18:13.560 [DefaultDispatcher-worker-3] TRACE io.ktor.server.routing.Routing - Trace for [register]
/, segment:0 -> SUCCESS @ /
  /login, segment:0 -> FAILURE "Selector didn't match" @ /login
  /register, segment:1 -> SUCCESS @ /register
    /register/(method:POST), segment:1 -> SUCCESS @ /register/(method:POST)
  /(authenticate auth-jwt), segment:0 -> SUCCESS @ /(authenticate auth-jwt)
    /(authenticate auth-jwt)/article, segment:0 -> FAILURE "Selector didn't match" @ /(authenticate auth-jwt)/article
  /(authenticate auth-jwt), segment:0 -> SUCCESS @ /(authenticate auth-jwt)
    /(authenticate auth-jwt)/category, segment:0 -> FAILURE "Selector didn't match" @ /(authenticate auth-jwt)/category
  /(authenticate auth-jwt), segment:0 -> SUCCESS @ /(authenticate auth-jwt)
    /(authenticate auth-jwt)/tag, segment:0 -> FAILURE "Selector didn't match" @ /(authenticate auth-jwt)/tag
  /image, segment:0 -> FAILURE "Selector didn't match" @ /image
Matched routes:
  "" -> "register" -> "(method:POST)"
Routing resolve result:
  SUCCESS @ /register/(method:POST)
2025-01-04 21:18:13.561 [DefaultDispatcher-worker-3] TRACE i.k.server.engine.DefaultTransform - No Default Transformations found for class io.ktor.utils.io.ByteChannel and expected type TypeInfo(com.steiner.vblog.request.RegisterRequest) for call /register
2025-01-04 21:18:13.575 [DefaultDispatcher-worker-8] TRACE i.k.s.p.statuspages.StatusPages - Call /register failed with cause java.lang.IncompatibleClassChangeError: Found interface io.ktor.server.routing.Routing, but class was expected
2025-01-04 21:18:13.575 [DefaultDispatcher-worker-8] TRACE i.k.s.p.statuspages.StatusPages - No handler found for exception: java.lang.IncompatibleClassChangeError: Found interface io.ktor.server.routing.Routing, but class was expected for call /register
2025-01-04 21:18:13.575 [DefaultDispatcher-worker-8] ERROR Application - Unhandled: POST - /register
java.lang.IncompatibleClassChangeError: Found interface io.ktor.server.routing.Routing, but class was expected
	at org.koin.ktor.ext.RoutingExtKt.getKoin(RoutingExt.kt:74)
	at com.steiner.vblog.route.RouteAuthenticationKt$routeAuthentication$$inlined$inject$default$4.invoke(RoutingExt.kt:76)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:83)
	at com.steiner.vblog.route.RouteAuthenticationKt.routeAuthentication$lambda$3(RouteAuthentication.kt:23)
	at com.steiner.vblog.route.RouteAuthenticationKt.access$routeAuthentication$lambda$3(RouteAuthentication.kt:1)
	at com.steiner.vblog.route.RouteAuthenticationKt$routeAuthentication$2.invokeSuspend(RouteAuthentication.kt:41)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:823)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)
2025-01-04 21:18:13.576 [DefaultDispatcher-worker-8] TRACE i.k.s.p.c.ContentNegotiation - Skipping response body transformation from HttpStatusCode to OutgoingContent for the POST /register request because the HttpStatusCode type is ignored. See [ContentNegotiationConfig::ignoreType].
2025-01-04 21:18:13.576 [DefaultDispatcher-worker-8] TRACE i.k.s.p.statuspages.StatusPages - No handler found for status code 500 Internal Server Error for call: /register
and this is the revelant code in routing
Copy code
fun Routing.routeAuthentication() {
    val audience: String by inject<String>(named("jwt.audience"))
    val domain: String by inject<String>(named("jwt.domain"))
    val secret: String by inject<String>(named("jwt.secret"))
    val userService: UserService by inject<UserService>()
so the problem is can I use
inject
in the
Routing
interface ??
a
a
I'm facing the same problem. @kurt_steiner How did you fix it?
Update: I was getting this issue due to the wrong dependency injection in my modules. Once I fixed the dependencies the issue is resolved now.