Hi! I generated Ktor project using generator on <k...
# ktor
d
Hi! I generated Ktor project using generator on ktor.io, then upgraded it to
1.0.0-beta-3
and kotlin
1.3.0
, but I cant run the server. I try this:
Copy code
$ ./gradlew run

> Task :run FAILED
Exception in thread "main" java.lang.IllegalArgumentException: Neither port nor sslPort specified. Use command line options -port/-sslPort or configure connectors in application.conf
        at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt:121)
        at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt)
        at io.ktor.server.engine.ApplicationEngineEnvironmentBuilder.build(ApplicationEngineEnvironment.kt:95)
        at io.ktor.server.engine.ApplicationEngineEnvironmentKt.applicationEngineEnvironment(ApplicationEngineEnvironment.kt:40)
        at io.ktor.server.engine.CommandLineKt.commandLineEnvironment(CommandLine.kt:50)
        at io.ktor.server.netty.EngineMain.main(EngineMain.kt:16)
Although I have perfectly valid port in `resources/application.conf`:
Copy code
ktor {
    deployment {
        port =  8080
    }
    application {
        modules = [ com.example.ApplicationKt.module ]
    }
}
What am I doing wrong?
📝 1
1
d
Uhm, which is the
mainClassName
in the
build.gradle
?
c
Also need to ensure that there is application.conf in the result classes/jar
d
Right now I’m updating stuff to beta-3, so I’ll fix stuff as required. So if you only changed the Ktor version, I’m going to find the issue soon
d
Copy code
application {
    mainClassName = "io.ktor.server.netty.EngineMain"
}
I've used kts files for this one (experimenting)
Also need to ensure that there is application.conf in the result classes/jar
How would I check this?
Going away for a while, thanks for the help. I may poke around a bit later, I'm trying ktor for the first time, so it's possible I did something stupid
c
Just tried it and there is no application.conf bundled
logger conf is is missing as well
So it looks like
kotlin.sourceSets["main"].resources.srcDirs("resources")
is not enough
d
Uhm. Also I guess that I should do an integration test that actually tries that the hello world allows is listening after running in the generator, because maybe it doesn’t work at all. I’ll check
Or maybe the integration check can just check that it can get the application.conf resource from standard java resources
d
Thanks for trying! Is there something I could do to work around this? P.S. I had to delete the
tar.gz
message above because I discovered that I shared a
.git
along with it, which contains a private url
d
Well I suggest you to use a normal
build.gradle
using plain groovy instead of Kotlin DSL until I find the right way to set up the resources folder
d
got it, thanks!
d
After some tries I have noticed that you cannot (or I was not able to find a way) to specify the resources folder with kotlin DSL when using Gradle 4.7. I have added a test to verify that resources folder is included correctly in both gradle and gradle with kotlin dsl. The solution was to use a greater version of gradle and
sourceSets["main"].resources.srcDir("resources")
instead of
kotlin.sourceSets["main"].resources.srcDir("resources")
d
this worked, thank you! I will stick with kts build files then (at least for now)
👍 1