尝试通过嵌入式Jetty服务器运行Ktor应用程序时如何避免java.lang.ExceptionInInitializerError?

我通过嵌入式Jetty服务器运行我的Ktor Web应用程序.该应用程序在IDE中运行良好.但是,一旦我用shadowJar将其打包并运行生成的胖jar,Jetty服务器就会遇到NoClassDefFoundError.我相信NoClassDefFoundError是由ExceptionInInitializerError引起的,因为在PreEncodedHttpField内部Jetty的静态初始化中存在ArrayIndexOutOfBoundsException.如何在IDE内部不会发生此错误?从胖罐运行Ktor应用程序时如何避免它?

02-06-2018 00:27:59.093 [qtp859617558-17] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.093 [qtp859617558-24] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.099 [qtp859617558-26] DEBUG org.eclipse.jetty.io.IdleTimeout - SocketChannelEndPoint@2d8b0948{/0:0:0:0:0:0:0:1:50406<->/0:0:0:0:0:0:0:1:9000,OPEN,fill=-,flush=-,to=10/30000}{io=0/0,kio=0,kro=0}-><null> idle timeout check, elapsed: 6 ms, remaining: 29994 ms
02-06-2018 00:27:59.099 [qtp859617558-17] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.099 [qtp859617558-24] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.099 [qtp859617558-26] DEBUG o.eclipse.jetty.io.AbstractEndPoint - onOpen SocketChannelEndPoint@2d8b0948{/0:0:0:0:0:0:0:1:50406<->/0:0:0:0:0:0:0:1:9000,OPEN,fill=-,flush=-,to=15/30000}{io=0/0,kio=0,kro=0}-><null>
02-06-2018 00:27:59.099 [qtp859617558-17] DEBUG o.e.j.u.t.Invocable$InvocableExecutor - org.eclipse.jetty.util.thread.Invocable$InvocableExecutor@4dfc073a invoked org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@543935e4
02-06-2018 00:27:59.099 [qtp859617558-24] DEBUG o.e.j.util.thread.QueuedThreadPool - ran org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@5689f60
02-06-2018 00:27:59.099 [qtp859617558-17] DEBUG o.e.j.u.t.strategy.EatWhatYouKill - EatWhatYouKill@707b1a44/org.eclipse.jetty.io.ManagedSelector$SelectorProducer@7132a9dc/PRODUCING/1/1 produce exit
02-06-2018 00:27:59.099 [qtp859617558-26] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.099 [qtp859617558-17] DEBUG o.e.j.util.thread.QueuedThreadPool - ran org.eclipse.jetty.io.ManagedSelector$$Lambda$26/86506638@2c7106d9
02-06-2018 00:27:59.100 [qtp859617558-26] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.100 [qtp859617558-26] DEBUG o.e.j.util.thread.QueuedThreadPool - ran org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@5ce56a5a
02-06-2018 00:27:59.093 [qtp859617558-20] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.095 [qtp859617558-22] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.ExceptionInInitializerError: null
at org.eclipse.jetty.server.HttpConnection.<clinit>(HttpConnection.java:54)
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclipse.jetty.http.PreEncodedHttpField.<clinit>(PreEncodedHttpField.java:71)
... 9 common frames omitted
02-06-2018 00:27:59.094 [qtp859617558-23] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.102 [qtp859617558-23] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.102 [qtp859617558-23] DEBUG o.e.j.util.thread.QueuedThreadPool - ran org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@752bc090
02-06-2018 00:27:59.102 [qtp859617558-20] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.102 [qtp859617558-20] DEBUG o.e.j.util.thread.QueuedThreadPool - ran org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@1985be4c
02-06-2018 00:27:59.103 [qtp859617558-22] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.ExceptionInInitializerError: null
at org.eclipse.jetty.server.HttpConnection.<clinit>(HttpConnection.java:54)
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclipse.jetty.http.PreEncodedHttpField.<clinit>(PreEncodedHttpField.java:71)
... 9 common frames omitted
02-06-2018 00:27:59.103 [qtp859617558-22] DEBUG o.e.j.util.thread.QueuedThreadPool - ran org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@3416caab
02-06-2018 00:27:59.103 [qtp859617558-18-acceptor-0@178f268a-ServerConnector@cfbc8e8{HTTP/1.1,[http/1.1, h2c]}{0.0.0.0:9000}] DEBUG org.eclipse.jetty.io.ManagedSelector - Queued change org.eclipse.jetty.io.ManagedSelector$Accept@6cf5cd13 on org.eclipse.jetty.io.ManagedSelector@440e3ce6 id=0 keys=1 selected=0
02-06-2018 00:27:59.108 [qtp859617558-16] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop woken up from select, 0/0 selected
02-06-2018 00:27:59.108 [qtp859617558-16] DEBUG org.eclipse.jetty.io.ManagedSelector - Running action org.eclipse.jetty.io.ManagedSelector$Accept@6cf5cd13
02-06-2018 00:27:59.108 [qtp859617558-16] DEBUG org.eclipse.jetty.io.ManagedSelector - Queued change org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@44ae85a2 on org.eclipse.jetty.io.ManagedSelector@440e3ce6 id=0 keys=1 selected=0
02-06-2018 00:27:59.108 [qtp859617558-16] DEBUG o.e.j.u.t.strategy.EatWhatYouKill - EatWhatYouKill@3e67f5f2/org.eclipse.jetty.io.ManagedSelector$SelectorProducer@fd53053/PRODUCING/1/1->IDLE/0/1 EPC! org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@44ae85a2
02-06-2018 00:27:59.109 [qtp859617558-19] DEBUG o.e.j.u.t.strategy.EatWhatYouKill - EatWhatYouKill@3e67f5f2/org.eclipse.jetty.io.ManagedSelector$SelectorProducer@fd53053/PRODUCING/0/1 produce non-blocking
02-06-2018 00:27:59.109 [qtp859617558-19] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
02-06-2018 00:27:59.109 [qtp859617558-16] DEBUG o.e.j.util.thread.QueuedThreadPool - queue EatWhatYouKill@3e67f5f2/org.eclipse.jetty.io.ManagedSelector$SelectorProducer@fd53053/PRODUCING/0/1
02-06-2018 00:27:59.109 [qtp859617558-16] DEBUG o.e.j.u.t.Invocable$InvocableExecutor - org.eclipse.jetty.util.thread.Invocable$InvocableExecutor@5ba4a467 invoke  org.eclipse.jetty.io.ManagedSelector$CreateEndPoint@44ae85a2
02-06-2018 00:27:59.109 [qtp859617558-16] DEBUG org.eclipse.jetty.io.IdleTimeout - SocketChannelEndPoint@56d0b70c{/0:0:0:0:0:0:0:1:50414<->/0:0:0:0:0:0:0:1:9000,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=0}-><null> idle timeout check, elapsed: 0 ms, remaining: 30000 ms
02-06-2018 00:27:59.110 [qtp859617558-16] DEBUG o.eclipse.jetty.io.AbstractEndPoint - onOpen SocketChannelEndPoint@56d0b70c{/0:0:0:0:0:0:0:1:50414<->/0:0:0:0:0:0:0:1:9000,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=0}-><null>
02-06-2018 00:27:59.110 [qtp859617558-16] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.113 [qtp859617558-26] DEBUG o.e.j.util.thread.QueuedThreadPool - run EatWhatYouKill@3e67f5f2/org.eclipse.jetty.io.Man053/PRODUCING/0/1
02-06-2018 00:27:59.113 [qtp859617558-26] DEBUG o.e.j.u.t.strategy.EatWhatYouKill - EatWhatYouKill@3e67f5f2/org.eclipse.jetty.io.ManagedSRODUCING/0/1 run
02-06-2018 00:27:59.116 [qtp859617558-16] DEBUG org.eclipse.jetty.io.ManagedSelector -
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.HttpConnection
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:85)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:482)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:424)
at org.eclipse.jetty.io.ManagedSelector.access$1600(ManagedSelector.java:61)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:603)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
02-06-2018 00:27:59.119 [qtp859617558-16] DEBUG o.e.j.u.t.Invocable$InvocableExecutor - org.eclipse.jetty.util.thread.Invocable$Invocablepse.jetty.io.ManagedSelector$CreateEndPoint@44ae85a2
02-06-2018 00:27:59.119 [qtp859617558-16] DEBUG o.e.j.u.t.strategy.EatWhatYouKill - EatWhatYouKill@3e67f5f2/org.eclipse.jetty.io.ManagedSRODUCING/1/1 produce exit
02-06-2018 00:27:59.119 [qtp859617558-16] DEBUG o.e.j.util.thread.QueuedThreadPool - ran org.eclipse.jetty.io.ManagedSelector$$Lambda$26/

我的gradle文件:

buildscript {
    ext.kotlin_version = '1.2.21'
    ext.ktorVersion = '0.9.1'

    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
    }
}

apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'

mainClassName = 'routing.MainKt'
shadowJar {
    baseName = 'baseName'
    classifier = null
    version = null
}

sourceCompatibility = 1.8
compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

kotlin {
    experimental {
        coroutines "enable"
    }
}

repositories {
    mavenCentral()
    jcenter()
    maven { url "https://dl.bintray.com/kotlin/kotlinx" }
    maven { url "https://dl.bintray.com/kotlin/ktor" }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

dependencies {
    // Core Kotlin libs
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

    // Core Ktor libs
    def withoutKotlin = {
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect'
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jre8'
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jre7'
    }
    implementation "io.ktor:ktor-server-core:$ktorVersion", withoutKotlin
    implementation "io.ktor:ktor-server-netty:$ktorVersion", withoutKotlin
    implementation "io.ktor:ktor-freemarker:$ktorVersion", withoutKotlin
    implementation "io.ktor:ktor-locations:$ktorVersion", withoutKotlin

    .... More dependencies
}

解决方法:

将以下内容添加到Gradle构建脚本中:

import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
shadowJar {
    transform(ServiceFileTransformer) {
        path = 'META-INF/services'
        include 'org.eclipse.jetty.http.HttpFieldPreEncoder'
    }
}

我最终发现shadowJar不是默认将我的“META-INF”文件合并在一起.这是一个问题,因为当Jetty服务器启动时,它引用“META-INF / services / org.eclipse.jetty.http.HttpFieldPreEncoder”来加载正确的HttpField编码器.由于我的服务文件未正确合并,因此仅加载了Http2编码器.这反过来导致JVM在Jetty试图静态初始化PreEncodedHttpField时抛出java.lang.ExceptionInInitializerError错误,这反过来又导致了Jetty的HttpConnection中的NoClassDefError

我发现了herehere的提示

上一篇:java – 杰克逊注释被忽略了


下一篇:SPARK-AM-TrackURL-UI-500