Kotlin/Corda/SpringBoot 应用程序导致 SLF4J StackOverflowError
Kotlin/Corda/SpringBoot application causing SLF4J StackOverflowError
我不完全确定为什么它停止工作。我的项目几周前还在运行,但我刚刚再次尝试 运行 它,我只是收到一个关于日志记录的 WhosebugError
我正在 运行ning 的应用程序不会导致此问题,因为我已将 main 方法替换为空的方法:
class Application {
companion object {
@JvmStatic
fun main(vararg args: String) {
println("Hello, world.");
}
}
}
在控制台中出现以下错误(我已经删除了大部分错误,因为它只是重复导致 WhosebugError 的原因):
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.11.2/4d44e4edc4a7fb39f09b95b09f560a15976fa1ba/log4j-slf4j-impl-2.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.WhosebugError
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:121)
at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
这些是我的 gradle 依赖项:
dependencies {
// Main
implementation "$kotlin_group:kotlin-stdlib-jdk8:$kotlin_version"
implementation "$corda_group:corda-core:$corda_release_version"
implementation "$corda_group:corda-rpc:$corda_release_version"
implementation "$springboot_group:spring-boot-starter-web:$springboot_release_version"
implementation "$newco_group:newco-kotlin-core:$newco_kotlin_core_release_version"
implementation "$newco_group:newco-kotlin-libex:$newco_libex_release_version"
implementation "$newco_group:newco-kotlin-libex-services:$newco_libex-services_release_version"
implementation "$newco_group:newco-corda-fintex-contract:$newco_fintex_release_version"
implementation "$newco_group:newco-corda-fintex-workflow:$newco_fintex_release_version"
implementation "$newco_group:newco-corda-fintex-integration:$newco_fintex_release_version"
implementation project(":cordapp-contract")
implementation project(":cordapp-workflow")
implementation project(":cordapp-integration")
// Test
testRuntimeOnly "$junit_group:junit-jupiter-engine:$junit_version"
testImplementation "$junit_group:junit-jupiter-api:$junit_version"
testImplementation "$kotlin_group:kotlin-test:$kotlin_version"
testImplementation "$corda_group:corda-node-driver:$corda_release_version"
}
我试过将此添加到 gradle 但无济于事:
configurations {
all {
exclude module: 'slf4j-log4j12'
exclude module: 'jms'
exclude module: 'jmxtools'
exclude module: 'jmxri'
}
}
有什么想法吗? - 我不知道从哪里开始
初始化日志接口和实现时似乎存在无限循环,这导致了 WhosebugError。
您的类路径上有多个日志绑定,如日志输出所示:
SLF4J: Class path contains multiple SLF4J bindings.
从您的依赖项中排除 log4j 或 logback 应该可以解决您的问题。
确保使用正确的排除引用。根据日志输出,我认为您应该排除 log4j-slf4j-impl
而不是 slf4j-log4j12
(或类似的东西)。
我不完全确定为什么它停止工作。我的项目几周前还在运行,但我刚刚再次尝试 运行 它,我只是收到一个关于日志记录的 WhosebugError
我正在 运行ning 的应用程序不会导致此问题,因为我已将 main 方法替换为空的方法:
class Application {
companion object {
@JvmStatic
fun main(vararg args: String) {
println("Hello, world.");
}
}
}
在控制台中出现以下错误(我已经删除了大部分错误,因为它只是重复导致 WhosebugError 的原因):
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.11.2/4d44e4edc4a7fb39f09b95b09f560a15976fa1ba/log4j-slf4j-impl-2.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.WhosebugError
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:121)
at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
这些是我的 gradle 依赖项:
dependencies {
// Main
implementation "$kotlin_group:kotlin-stdlib-jdk8:$kotlin_version"
implementation "$corda_group:corda-core:$corda_release_version"
implementation "$corda_group:corda-rpc:$corda_release_version"
implementation "$springboot_group:spring-boot-starter-web:$springboot_release_version"
implementation "$newco_group:newco-kotlin-core:$newco_kotlin_core_release_version"
implementation "$newco_group:newco-kotlin-libex:$newco_libex_release_version"
implementation "$newco_group:newco-kotlin-libex-services:$newco_libex-services_release_version"
implementation "$newco_group:newco-corda-fintex-contract:$newco_fintex_release_version"
implementation "$newco_group:newco-corda-fintex-workflow:$newco_fintex_release_version"
implementation "$newco_group:newco-corda-fintex-integration:$newco_fintex_release_version"
implementation project(":cordapp-contract")
implementation project(":cordapp-workflow")
implementation project(":cordapp-integration")
// Test
testRuntimeOnly "$junit_group:junit-jupiter-engine:$junit_version"
testImplementation "$junit_group:junit-jupiter-api:$junit_version"
testImplementation "$kotlin_group:kotlin-test:$kotlin_version"
testImplementation "$corda_group:corda-node-driver:$corda_release_version"
}
我试过将此添加到 gradle 但无济于事:
configurations {
all {
exclude module: 'slf4j-log4j12'
exclude module: 'jms'
exclude module: 'jmxtools'
exclude module: 'jmxri'
}
}
有什么想法吗? - 我不知道从哪里开始
初始化日志接口和实现时似乎存在无限循环,这导致了 WhosebugError。
您的类路径上有多个日志绑定,如日志输出所示:
SLF4J: Class path contains multiple SLF4J bindings.
从您的依赖项中排除 log4j 或 logback 应该可以解决您的问题。
确保使用正确的排除引用。根据日志输出,我认为您应该排除 log4j-slf4j-impl
而不是 slf4j-log4j12
(或类似的东西)。