title: Why does my Ktor app fail after few seconds?
body: <p>I have a small <strong>Ktor</strong> app (I know it's a stupid app, I am a beginner trying to learn <strong>Ktor</strong>):</p>
  <pre><code>import com.auth0.jwt.JWT
  import com.auth0.jwt.JWTVerifier
  import com.auth0.jwt.algorithms.Algorithm
  import io.ktor.application.*
  import io.ktor.auth.*
  import io.ktor.auth.jwt.*
  import io.ktor.features.*
  import io.ktor.jackson.*
  import io.ktor.response.*
  import io.ktor.routing.*
  import io.ktor.server.netty.*
  
  private val algorithm = Algorithm.HMAC256(&quot;secret&quot;)
  
  private fun makeJwtVerifier(issuer: String, audience: String): JWTVerifier = JWT
      .require(algorithm)
      .withAudience(audience)
      .withIssuer(issuer)
      .build()
  
  fun main(args: Array&lt;String&gt;): Unit = EngineMain.main(args)
  
  fun Application.module(testing: Boolean = false) {
      val jwtIssuer = environment.config.property(&quot;jwt.domain&quot;).getString()
      val jwtAudience = environment.config.property(&quot;jwt.audience&quot;).getString()
      val jwtRealm = environment.config.property(&quot;jwt.realm&quot;).getString()
  
      install(ContentNegotiation) {
          jackson()
      }
  
      install(Authentication) {
          basic {
              realm = jwtRealm
              validate { credentials -&gt;
                  UserIdPrincipal(credentials.name)
              }
          }
          jwt {
              realm = jwtRealm
              verifier(makeJwtVerifier(jwtIssuer, jwtAudience))
              validate { credential -&gt;
                  if (credential.payload.audience.contains(jwtAudience)) JWTPrincipal(credential.payload) else null
              }
          }
      }
  
      routing {
          authenticate(&quot;basic&quot;) {
              post(&quot;/auth/login&quot;) {
                  val principal = call.principal&lt;UserIdPrincipal&gt;() ?: error (&quot;no auth found&quot;)
                  call.respondText(principal.name)
              }
          }
      }
  }
  </code></pre>
  <p>And <strong>application.conf</strong>:</p>
  <pre><code>ktor {
      development = true
      deployment {
          port = 8080
          watch = [ com.contedevel ]
      }
      application {
          modules = [ com.contedevel.backend.ApplicationKt.module ]
      }
      jwt {
          domain = &quot;https://localhost/&quot;
          audience = &quot;jwt-audience&quot;
          realm = &quot;acupoftea&quot;
      }
  }
  </code></pre>
  <p>My <strong>build.gradle.kts</strong>:</p>
  <pre><code>import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  
  plugins {
      application
      kotlin(&quot;jvm&quot;) version &quot;1.4.30&quot;
  }
  
  group = &quot;com.contedevel&quot;
  version = &quot;1.0-SNAPSHOT&quot;
  
  application {
      mainClass.set(&quot;io.ktor.server.netty.EngineMain&quot;)
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      // Standard
      implementation(kotlin(&quot;stdlib&quot;))
      // Ktor
      implementation(&quot;io.ktor:ktor-server-core:1.5.2&quot;)
      implementation(&quot;io.ktor:ktor-server-netty:1.5.2&quot;)
      implementation(&quot;ch.qos.logback:logback-classic:1.2.1&quot;)
      // Jackson
      implementation(&quot;io.ktor:ktor-jackson:1.5.2&quot;)
      // JWT
      implementation(&quot;io.ktor:ktor-auth:1.5.2&quot;)
      implementation(&quot;io.ktor:ktor-auth-jwt:1.5.2&quot;)
      // Testing
      testImplementation(kotlin(&quot;test-junit&quot;))
  }
  
  tasks.test {
      useJUnit()
  }
  
  tasks.withType&lt;KotlinCompile&gt;() {
      kotlinOptions.jvmTarget = &quot;13&quot;
  }
  </code></pre>
  <p>Then I try to start the app by <code>./gradlew run</code>, it shows few warnings and fails:</p>
  <pre><code>01:53:18.381 [Thread-0] DEBUG io.netty.util.internal.NativeLibraryLoader - netty_transport_native_kqueue cannot be loaded from java.library.path, now trying export to -Dio.netty.native.workdir: /var/folders/d5/x8gp_xv95xb0l5y3_gq_m1840000gn/T
  java.lang.UnsatisfiedLinkError: no netty_transport_native_kqueue in java.library.path: /Users/denis/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
          at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2447)
          at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:809)
          at java.base/java.lang.System.loadLibrary(System.java:1893)
          at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
          at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:351)
          at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
          at io.netty.channel.kqueue.Native.loadNativeLibrary(Native.java:128)
          at io.netty.channel.kqueue.Native.&lt;clinit&gt;(Native.java:60)
          at io.netty.channel.kqueue.KQueue.&lt;clinit&gt;(KQueue.java:37)
          at io.ktor.server.netty.EventLoopGroupProxy$Companion.create(NettyApplicationEngine.kt:232)
          at io.ktor.server.netty.NettyApplicationEngine$workerEventGroup$2.invoke(NettyApplicationEngine.kt:98)
          at io.ktor.server.netty.NettyApplicationEngine$workerEventGroup$2.invoke(NettyApplicationEngine.kt:28)
          at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
          at io.ktor.server.netty.NettyApplicationEngine.getWorkerEventGroup(NettyApplicationEngine.kt)
          at io.ktor.server.netty.NettyApplicationEngine.access$getWorkerEventGroup$p(NettyApplicationEngine.kt:28)
          at io.ktor.server.netty.NettyApplicationEngine$engineDispatcherWithShutdown$2.invoke(NettyApplicationEngine.kt:118)
          at io.ktor.server.netty.NettyApplicationEngine$engineDispatcherWithShutdown$2.invoke(NettyApplicationEngine.kt:28)
          at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
          at io.ktor.server.netty.NettyApplicationEngine.getEngineDispatcherWithShutdown(NettyApplicationEngine.kt)
          at io.ktor.server.netty.NettyApplicationEngine.stop(NettyApplicationEngine.kt:181)
          at io.ktor.server.engine.ApplicationEngineJvmKt.stop(ApplicationEngineJvm.kt:18)
          at io.ktor.server.netty.EngineMain$main$1.invoke(EngineMain.kt:24)
          at io.ktor.server.netty.EngineMain$main$1.invoke(EngineMain.kt:14)
          at io.ktor.server.engine.ShutdownHook.run(ShutdownHook.kt:37)
          Suppressed: java.lang.UnsatisfiedLinkError: no netty_transport_native_kqueue in java.library.path: /Users/denis/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
                  at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2447)
                  at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:809)
                  at java.base/java.lang.System.loadLibrary(System.java:1893)
                  at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
                  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                  at java.base/java.lang.reflect.Method.invoke(Method.java:564)
                  at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:385)
                  at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
                  at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:377)
                  at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:341)
                  ... 19 common frames omitted
  01:53:18.394 [Thread-0] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 24
  01:53:18.401 [Thread-0] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
  01:53:18.401 [Thread-0] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
  01:53:18.404 [Thread-0] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
  01:53:18.404 [Thread-0] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
  01:53:18.408 [Thread-0] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
  
  &gt; Task :run FAILED
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':run'.
  &gt; Process 'command '/Library/Java/JavaVirtualMachines/liberica-jdk-15-full.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  
  * Get more help at https://help.gradle.org
  
  BUILD FAILED in 8s
  </code></pre>
  <p>However, when I call <code>./gradlew build</code> all is successful... What's my mistake?</p>
  <p><strong>P.S.</strong> I use <strong>Liberica JDK v.15</strong>.</p>