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

Nazar Pohonchuk

02/24/2023, 8:25 PM
Hi! When I am creating a Ktor project in IntelliJ without adding any plugins (just clicking next) and run the project it works, but with this message
Copy code
023-02-24 22:16:07.940 [main] INFO  ktor.application - Autoreload is disabled because the development mode is off.
Even when I write this in my build.gradle.kts file
Copy code
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=true")
But the main problem is that when I create a new project and add some plugins, it stops working with this message
Copy code
2023-02-24 22:10:07.243 [main] INFO  ktor.application - Autoreload is disabled because the development mode is off.
Exception in thread "main" io.ktor.server.config.ApplicationConfigurationException: Property jwt.audience not found.
	at io.ktor.server.config.MapApplicationConfig.property(MapApplicationConfig.kt:55)
	at com.example.plugins.SecurityKt$configureSecurity$1$1.invoke(Security.kt:13)
	at com.example.plugins.SecurityKt$configureSecurity$1$1.invoke(Security.kt:12)
	at io.ktor.server.auth.jwt.JWTAuthKt.jwt(JWTAuth.kt:324)
	at io.ktor.server.auth.jwt.JWTAuthKt.jwt$default(JWTAuth.kt:320)
	at com.example.plugins.SecurityKt$configureSecurity$1.invoke(Security.kt:12)
	at com.example.plugins.SecurityKt$configureSecurity$1.invoke(Security.kt:11)
	at io.ktor.server.auth.Authentication$Companion.install(Authentication.kt:98)
	at io.ktor.server.auth.Authentication$Companion.install(Authentication.kt:94)
	at io.ktor.server.application.ApplicationPluginKt.install(ApplicationPlugin.kt:98)
	at io.ktor.server.auth.AuthenticationKt.authentication(Authentication.kt:128)
	at com.example.plugins.SecurityKt.configureSecurity(Security.kt:11)
	at com.example.ApplicationKt.module(Application.kt:14)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97)
	at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Static.call(CallerImpl.kt:106)
	at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108)
	at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:159)
	at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:112)
	at io.ktor.server.engine.internal.CallableUtilsKt.callFunctionWithInjection(CallableUtils.kt:119)
	at io.ktor.server.engine.internal.CallableUtilsKt.executeModuleFunction(CallableUtils.kt:36)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$launchModuleByName$1.invoke(ApplicationEngineEnvironmentReloading.kt:331)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$launchModuleByName$1.invoke(ApplicationEngineEnvironmentReloading.kt:330)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.avoidingDoubleStartupFor(ApplicationEngineEnvironmentReloading.kt:355)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.launchModuleByName(ApplicationEngineEnvironmentReloading.kt:330)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.access$launchModuleByName(ApplicationEngineEnvironmentReloading.kt:32)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$instantiateAndConfigureApplication$1.invoke(ApplicationEngineEnvironmentReloading.kt:318)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$instantiateAndConfigureApplication$1.invoke(ApplicationEngineEnvironmentReloading.kt:309)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.avoidingDoubleStartup(ApplicationEngineEnvironmentReloading.kt:337)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.instantiateAndConfigureApplication(ApplicationEngineEnvironmentReloading.kt:309)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createApplication(ApplicationEngineEnvironmentReloading.kt:150)
	at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.start(ApplicationEngineEnvironmentReloading.kt:276)
	at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:212)
	at com.example.ApplicationKt.main(Application.kt:10)
	at com.example.ApplicationKt.main(Application.kt)

Process finished with exit code 1
Even with this line in build.gradle.kts
Copy code
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=true")
Could anyone help me please?
a

Aleksei Tirman [JB]

02/24/2023, 9:11 PM
Can you please share the archive of this project?
n

Nazar Pohonchuk

02/24/2023, 9:41 PM
a

Aleksei Tirman [JB]

02/28/2023, 12:22 PM
To solve your problem you need to use an application config with JWT parameters filled in. The modified project is attached.
2 Views