Mark Fisher
01/09/2025, 7:46 PM/bw/App.kt
) is:
fun main() = runBlocking {
logger.info("Starting Bouncy World Service at ${Date()}")
val env = applicationEnvironment {
config = ApplicationConfig("application.conf")
}
val worldConfig = WorldConfig(env.config)
val world = WorldFactory.create(worldConfig)
I can see and have validated the application.conf file in the root of the jar folder.
When starting up, I see the logger information, but the instantiation of worldConfig fails, because there's nothing in env.config (I print out the keys in the init section of WorldConfig, and it's showing an empty list).
My gradle build has the main class set with:
jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
mainRun {
mainClass.set("bw.AppKt")
}
This works fine outside a jar file invocation (i.e. clicking the start button in IntelliJ for the application) i.e. via:
jvmRun -DmainClass=bw.AppKt --quiet
Can anyone suggest why the config isn't being read when running the application via
java -jar path/to/my.jar
I tried adding -conf
param, but as I'm not using the EngineMain to create the server, it's not doing anything.Mark Fisher
01/09/2025, 8:33 PMio.ktor.server.config.HoconConfigLoader
is not available when running by the jar, but only when run from the IDE.
Does anyone know how to get that to load in the jar too?Mark Fisher
01/09/2025, 8:34 PMio/ktor/server/config/HoconConfigLoader.class
exists in the fat jar. Now just need to know why it's not registeringMark Fisher
01/09/2025, 8:39 PMio.ktor.server.config.ConfigLoader
file only contains:
io.ktor.server.config.yaml.YamlConfigLoader
and not
io.ktor.server.config.HoconConfigLoader
Mark Fisher
01/09/2025, 9:04 PMAleksei Tirman [JB]
01/10/2025, 8:58 AMHoconConfigLoader
class is part of the ktor-server-core
package, so it should be loaded anyway. Do you plan to use the YAML or the HOCON configuration?Mark Fisher
01/10/2025, 10:24 AMAleksei Tirman [JB]
01/10/2025, 10:32 AMHoconConfigLoader
class directly to load the config.Mark Fisher
01/10/2025, 10:45 AM