https://kotlinlang.org logo
#ktor
Title
# ktor
j

James Black

04/08/2022, 5:15 AM
Unable to start a ktor server with this error. Exception in thread "main" io.ktor.server.engine.internal.ReloadingException: Module function cannot be found for the fully qualified name 'com.blackfox.myoutfitpicker.ApplicationKt.module' at io.ktor.server.engine.internal.CallableUtilsKt.executeModuleFunction(CallableUtils.kt:27) I am following the instructions at https://ktor.io/docs/eap/creating-http-apis.html#order_routes
Copy code
import io.ktor.server.application.*
import com.blackfox.myoutfitpicker.plugins.configureRouting
import com.blackfox.myoutfitpicker.plugins.configureSerialization

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

fun Application.module() {
    configureRouting()
    configureSerialization()
}
I have no idea what I am doing wrong.
s

Steffen Lien

04/08/2022, 6:43 AM
What's in your
application.conf
? Might be the package-name there is different so it can't find the specified module perhaps?
a

Aleksei Tirman [JB]

04/08/2022, 8:50 AM
And check that a source file with the
Application.module
definition is named
Application.kt
.
j

James Black

04/09/2022, 7:01 AM
@Steffen Lien and @Aleksei Tirman [JB]
Copy code
ktor {
    deployment {
        port = 8080
        port = ${?PORT}
    }
    application {
        modules = [ com.blackfox.myoutfitpicker.ApplicationKt.module ]
    }
}
And the application source, which you can also see at https://github.com/jblack975/MyOutfitPicker
Copy code
package com.blackfox.myoutfitpicker

import io.ktor.server.application.*
import com.blackfox.myoutfitpicker.plugins.configureRouting
import com.blackfox.myoutfitpicker.plugins.configureSerialization

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

fun Application.module() {
    configureRouting()
    configureSerialization()
}
s

Steffen Lien

04/09/2022, 7:23 AM
@James Black Either change the filename
Main.kt
to
Application.kt
or change the modules part in your
application.conf
to
modules = [ com.blackfox.myoutfitpicker.MainKt.module ]
. The
<File>Kt
part of the modules is looking for a specific file called exactly that as I recall (haven't tried to run your project)
j

James Black

04/09/2022, 7:41 AM
Thanks @Steffen Lien. I didn't realize the filename was the important part here. It runs now.
👍 2
267 Views