Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get error while injecting inside Route in ktor #2008

Open
mhdabbaghy opened this issue Sep 27, 2024 · 1 comment
Open

Get error while injecting inside Route in ktor #2008

mhdabbaghy opened this issue Sep 27, 2024 · 1 comment

Comments

@mhdabbaghy
Copy link

Describe the bug
In ktor when i want to inject a class inside my Route I'm getting exception:

Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/server/routing/RoutingKt
at org.koin.ktor.ext.RouteExtKt.getKoin(RouteExt.kt:74)

Here is my code:
`
fun Route.authRoutes() {

val authService: AuthService by inject()

route("/auth") {
    loginRoute(authService)
}

}
`

but when I change code to

`
fun Route.authRoutes() {

val authService: AuthService by application.inject()

route("/auth") {
    loginRoute(authService)
}

}
`
It works fine

Koin version: 4.0.0
Ktor version: 3.0.0-rc-1
kotlin version: 2.0.20

@octogene
Copy link

octogene commented Oct 3, 2024

As a workaround you can build or use the package from this PR : #1978
Tested on my project after a rebase on 4.0.0 and it works without problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants