question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module function cannot be found in 1.2.0

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
gandrewstonecommented, Mar 25, 2021

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.

5reactions
msenincommented, May 17, 2019

Same problem. It is not good that users cannot run projects generated by KTor website 😦

In ApplicationEngineEnvironmentReloading.kt at last line of isApplicableFunction for default boolean parameter we have it.kind == KParameter.Kind.VALUE, not KParameter.Kind.INSTANCE.

        private fun KFunction<*>.isApplicableFunction(): Boolean {
            if (isOperator || isInfix || isInline || isAbstract) return false
            if (isSuspend) return false // not supported yet

            extensionReceiverParameter?.let {
                if (!isApplication(it) && !isApplicationEnvironment(it)) return false
            }

            javaMethod?.let {
                if (it.isSynthetic) return false

                // static no-arg function is useless as a module function since no application instance available
                // so nothing could be configured
                if (Modifier.isStatic(it.modifiers) && parameters.isEmpty()) {
                    return false
                }
            }

            return parameters.all { isApplication(it) || isApplicationEnvironment(it) || it.kind == KParameter.Kind.INSTANCE }
        }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ktor - Quickstart new project from plugin throwing Error
java.lang.ClassNotFoundException : Module function cannot be found for the fully qualified name 'com.example.ApplicationKt.module' ?
Read more >
6.4. Imputation of missing values - Scikit-learn
Univariate feature imputation¶. The SimpleImputer class provides basic strategies for imputing missing values. Missing values can be imputed with a provided ...
Read more >
Use Java 8 language features and APIs - Android Developers
Discover the Java 8 language features you can use, how to properly configure your project to use them, and any known issues you...
Read more >
Version Constraints - Configuration Language | Terraform
Version constraint strings specify a range of acceptable versions for modules, providers, and Terraform itself. Learn version constraint syntax and ...
Read more >
Azure Durable Function - Python - Module not found
Azure Durable Function - Python - Module not found ... aiohttp==3.8.3; aiosignal==1.2.0; anyio==3.6.1; async-timeout==4.0.2; attrs==22.1.0 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found