ktor: Module function cannot be found in 1.2.0
Ktor Version
1.2.0
Ktor Engine Used(client or server and name)
Ktor server
JVM Version, Operating System and Relevant Context
java version “1.8.0_151” MacOS
Feedback
I’ve migrated mi running project from 1.1.5 to 1.2.0 and I’ve the following error.
Exception in thread "main" java.lang.ClassNotFoundException: Module function cannot be found for the fully qualified name 'cat.helm.catformacio.ApplicationKt.module'
Has the configuration changed?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 19 (1 by maintainers)
Commits related to this issue
- Fix module function lookup with default args (#1132) — committed to ktorio/ktor by deleted user 5 years ago
- Fix module function lookup with default args (#1132) — committed to ktorio/ktor by deleted user 5 years ago
This worked for me ONLY if my file name was exactly Application.kt (I had chosen server.kt), and my function as: fun Application.module() {} (no parameter). This differs from the ktor docs https://ktor.io/docs/create-server.html#engine-main.
The design decision to wrap “main” and force the user to conform to your custom “main” format is never a good one because your lib is not the heart of my program. Let me be in control and pass you a callback function, if you absolutely MUST schedule the run of “main” yourself.
The decision to define what is “main” in a conf file is even crazier. What web app needs entry point A today, but tomorrow somehow there’s a compelling reason to stop the server (which should never happen) and restart at entry point B?
This whole .conf file is just one more thing that can go wrong, and is massive overkill to define the port and IP, as is clear by all the search hits (should be optional).
The “embeddedServer” interface is nice clean and kotlin-like. But based on the docs, etc, it seems like it may be meant for debug not deploy? Does it have perf or other limitations? If it does not, it would be nice to make that clear.
Same problem. It is not good that users cannot run projects generated by KTor website 😦
In
ApplicationEngineEnvironmentReloading.kt
at last line ofisApplicableFunction
for default boolean parameter we have it.kind == KParameter.Kind.VALUE, not KParameter.Kind.INSTANCE.Fixed in 1.2.1
Can confirm. This way it works:
However, with a default parameter and @JvmOverloads, it does not.
My problem was that i whas ussing:
fun Application.module(testing: Boolean = false) {}
It seems that now the parameter is not allowed, so I’ve had to add a wrapper function without parameter.So for me you can close the issue.
It’s Not fixed yet. I’m using 1.2.1 and getting the same error. Only works using davidepianca98 solution.
The solution for we was removing both the testing parameter and the JvmOverloads annotation so that now it’s just
fun Application.module() {
But waiting for a real fix because the testing boolean was useful.I have the same problem. Also macOS, JDK8, ktor 1.2.
Check the package of your kt file