对于使用MINA SSHD的项目,Gradle测试Scoverage失败,并出现NoClassDefFoundError

vhipe2zx  于 2022-11-14  发布在  其他
关注(0)|答案(1)|浏览(170)

我有一组使用MINA SSHD(org.apache.sshd)的类。这些类的测试已经在MINA 1.7.0版本中运行过。现在我将迁移到2.8.0,并重新运行测试。我从MINA中得到两个特定类的NoClassDefFoundError:

22:40:46.606 [sshd-SshServer[55f94b13](port=8022)-nio2-thread-2] DEBUG org.apache.sshd.server.session.ServerSessionImpl - readIdentification(ServerSessionImpl[null@/127.0.0.1:56869]) client version string: SSH-2.0-APACHE-SSHD-2.8.0
Exception in thread "sshd-SshClient[ef9d35b]-nio2-thread-1" java.lang.NoClassDefFoundError: Could not initialize class org.apache.sshd.common.util.logging.LoggingUtils
    at org.apache.sshd.common.util.logging.AbstractLoggingBean.debug(AbstractLoggingBean.java:82)
    at org.apache.sshd.common.io.nio2.Nio2Connector.access$200(Nio2Connector.java:42)
    at org.apache.sshd.common.io.nio2.Nio2Connector$ConnectionCompletionHandler.onCompleted(Nio2Connector.java:180)
    at org.apache.sshd.common.io.nio2.Nio2Connector$ConnectionCompletionHandler.onCompleted(Nio2Connector.java:116)
    at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37)
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    at sun.nio.ch.Invoker$2.run(Invoker.java:218)
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)

22:59:22.798 [sshd-SshServer[55f94b13](port=8022)-nio2-thread-2] DEBUG org.apache.sshd.server.session.SessionFactory - messageReceived(Nio2Session[local=/127.0.0.1:8022, remote=/127.0.0.1:57245]) failed NoClassDefFoundError to handle message: Could not initialize class org.apache.sshd.common.SshConstants$LazyMessagesMapHolder
java.lang.NoClassDefFoundError: Could not initialize class org.apache.sshd.common.SshConstants$LazyMessagesMapHolder
    at org.apache.sshd.common.SshConstants.getCommandMessageName(SshConstants.java:200)

奇怪的是,它说它找不到属于sshd-common工件的类,而其他类却可以毫无问题地找到。
在我的主要依赖项中,我使用的是2.8.0:

dependency group: 'org.apache.sshd', name: 'sshd-common', version: '2.8.0'
        dependency group: 'org.apache.sshd', name: 'sshd-core', version: '2.8.0'
        dependency group: 'org.apache.sshd', name: 'sshd-scp', version: '2.8.0'
        dependency group: 'org.apache.sshd', name: 'sshd-sftp', version: '2.8.0'

在编写代码和测试的特定项目中,我也引入了特定的版本:

dependencies {
    compile group: 'org.apache.sshd', name: 'sshd-common', version: '2.8.0'
    compile group: 'org.apache.sshd', name: 'sshd-core', version: '2.8.0'
    compile group: 'org.apache.sshd', name: 'sshd-scp', version: '2.8.0'
    compile group: 'org.apache.sshd', name: 'sshd-sftp', version: '2.8.0'

  compile project(':commands:expect4j')
  compile project(':common:utils')
    compile group: 'net.jcazevedo', name: 'moultingyaml_2.12'
    compile group: 'org.scala-lang', name: 'scala-reflect', version: scalaVersion
    compile group: 'org.bouncycastle', name: 'bcprov-jdk15on'
    compile group: 'org.bouncycastle', name: 'bcpkix-jdk15on'
    compile group: 'com.typesafe.scala-logging', name: 'scala-logging_2.12'
}

apply from: new File(rootProject.projectDir, 'gradle/scala.gradle')

没有其他对org.apache.sshd的引用。我遗漏了什么?

axr492tv

axr492tv1#

Mina 2.8.0使用slf4j版本1.7.32。
请尝试添加此依赖版本。

implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.32'

相关问题