我已经使用 Kotlin 协程扩展成功创建了一个带有少量 verticles 的 shadow-jar,并且能够通过vertx run
命令行运行它们,同时指定我的 jar 的路径,除了一个在其启动时创建 telnet shell 的 Verticle 异常:
java.lang.NoClassDefFoundError: io.vertx.ext.shell.term.TelnetTermOptions
at io.vertx.kotlin.ext.shell.term.TelnetTermOptionsKt.telnetTermOptionsOf(TelnetTermOptions.kt:119)
at io.vertx.kotlin.ext.shell.term.TelnetTermOptionsKt.telnetTermOptionsOf$default(TelnetTermOptions.kt:119)
at **********************.ContactsReceiver.start(ContactsReceiver.kt:20)
at io.vertx.kotlin.coroutines.CoroutineVerticle$start$1.invokeSuspend(CoroutineVerticle.kt:53)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
at io.vertx.kotlin.coroutines.VertxCoroutineExecutor.execute(VertxCoroutine.kt:214)
at kotlinx.coroutines.ExecutorCoroutineDispatcherBase.dispatch(Executors.kt:64)
at kotlinx.coroutines.DispatchedKt.resumeCancellable(Dispatched.kt:413)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:25)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:154)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:54)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
at io.vertx.kotlin.coroutines.CoroutineVerticle.start(CoroutineVerticle.kt:51)
at io.vertx.core.Verticle.start(Verticle.java:66)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:556)
at io.vertx.core.impl.DeploymentManager$$Lambda$126.0000000063922220.handle(Unknown Source)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369)
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
at io.vertx.core.impl.EventLoopContext$$Lambda$127.0000000060DA8B00.run(Unknown Source)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:831)
我的项目是使用 Gradle (Kotlin DSL) 构建的
这些是我的 vert.x 依赖项:
io.vertx:vertx-core
io.vertx:vertx-lang-kotlin
io.vertx:vertx-lang-kotlin-coroutines
io.vertx:vertx-shell
io.vertx:vertx-auth-shiro
io.vertx:vertx-tcp-eventbus-bridge
我的影子罐子任务配置如下:
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
classifier = "fat"
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
minimize()
manifest {
attributes["Main-Verticle"] = vertx.mainVerticle
}
mergeServiceFiles {
include("META-INF/services/io.vertx.core.spi.VerticleFactory")
}
}
似乎minimize()
不是问题,但重要的是,如果我从main
函数 evrything 以编程方式部署该垂直,并且我得到了 telnet shell。
也许我在影子 jar 任务的清单配置中遗漏了一些东西?