- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在通过嵌入式 Jetty 服务器运行我的 Ktor Web 应用程序。该应用程序在 IDE 中运行良好。但是,一旦我用 shadowJar 打包并运行生成的 fat jar,Jetty 服务器就会遇到 NoClassDefFoundError。我相信 NoClassDefFoundError 是由 ExceptionInInitializerError 引起的,该异常是由于 PreEncodedHttpField 内部的 Jetty 静态初始化内部的 ArrayIndexOutOfBoundsException 引起的。 IDE内部怎么不会出现这个错误?从 fat jar 运行 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
关于java - 尝试通过嵌入式 Jetty 服务器运行 Ktor 应用程序时如何避免 java.lang.ExceptionInInitializerError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48636944/
我正在挖掘内置配置支持,并想使用它(而不是仅仅将我自己的配置与 Ktor 的配置一起使用),但我很难弄清楚如何以一种干净的方式来实现它。我有这个,它正在工作,但它真的很难看,我觉得必须有更好的方法:
我目前正在使用 Ktor Netty Engine 创建我的应用程序 当用户向我的服务器发送请求但没有发现任何功能时,我搜索了文档以处理发送电子邮件的任何功能。 post("/api/v1/auth"
KTor 与单元测试配合得很好,但我如何启动我的 ktor 服务器进行集成测试? 我的测试是这样的: @ExperimentalCoroutinesApi class HttpClientTest {
我想弄清楚如何使用 Ktor 检查 http 请求的 http 状态代码 我有一个像这样的简单 GET 请求,其中包含一个 HttpResponseObject 保存服务器返回的数据以及我控制的任何服
我刚刚开始探索 KMM,到目前为止看起来确实不错。 基本上,我想要在一个地方全局处理所有 http 错误代码(如 401、404、500)。 但是,我不确定如何与响应交互。 我在 HttpClient
我刚刚开始探索 KMM,到目前为止看起来确实不错。 基本上,我想要在一个地方全局处理所有 http 错误代码(如 401、404、500)。 但是,我不确定如何与响应交互。 我在 HttpClient
我正在尝试调用一个 twitter 端点,该端点为您提供持续的 json 结果流回客户端 https://documenter.getpostman.com/view/9956214/T1LMiT5U
我正在使用Ktor从Moshi转换为kotlinx序列化的过程,当我尝试提出获取数据的请求时,出现此错误 kotlinx.serialization.MissingFieldException: Fi
我正在将 Ktor 与 kotlin multiplatform 一起使用,我试图弄清楚为什么我没有收到任何抛出的异常。在我的客户端配置中,我使用了 HttpResonseValidator检查返回的
我需要根据正文为请求添加 header 。如何为客户端请求添加拦截器?我试过了 httpClient.requestPipeline.intercept(HttpRequestPipeline.Se
引用Ktor Pool implementation ,有人可以解释一下这个 pop 和 push 实现背后的概念。我试着单步执行代码,但在研究代码后我仍然不聪明。 下面是我难以理解的代码片段:
我是后端开发的新手。基本上,我想创建一个强大而简单的应用程序,它将在参数中接受一个 zip 文件 URL,然后从 URL 下载 zip 文件,最后解压缩 zip 并返回其中的 bin 文件。注意:zi
我想更好地了解Ktor如何处理静态内容的路由。我的静态文件夹(工作目录)中具有以下层次结构: - static - index.html - (some files) - static -
我是 Kotlin 和 Ktor 的新手,所以我尝试做简单的发布请求。正如你在下面看到的,没有什么特别的。 routing { post("/articles/add"){
KTOR中HttpClient的正确用法是什么?我应该在每个应用程序生命周期中像单例一样使用它,还是应该在每个请求中创建它? 最佳答案 我想说,如果您需要连接多个逻辑服务,则每个应用程序可能有多个客户
我做了什么? 在 build.gradle 下添加了依赖项 implementation "io.ktor:ktor:1.3.2" implementation "io.ktor:ktor-serve
我正在使用 ktor v0.9.2,我想根据用户是否通过身份验证为同一路由发送不同的内容。 我遇到的问题是我无法访问 authenticate { } 之外的主体。堵塞。 我的设置是这样的: data
我是 Kotlin 和 Ktor 的新手,想看看身份验证部分,所以我得到了以下代码。 路由“/”和“/bye”工作正常,但路由“登录”给定空白页! package blog import kotlin
当我使用 Retrofit 时,我可以轻松地创建日志记录拦截器以在 logcat 上查看带有正文和 header 的调用: val loggingInterceptor = HttpLoggingI
我一直在关注 ktor tutorial用于制作网站并注意到每次我对资源文件进行更改时,我都必须重新编译才能在浏览器中看到它的更新。有什么方法可以热重载静态文件以加快开发速度吗?如果重要的话,我会使用
我是一名优秀的程序员,十分优秀!