我正在使用Apache Mina SSHD编写SSH服务器。服务器启动正常,但当我尝试连接到服务器时,我得到“没有会话可用”异常。这是服务器的代码:
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(port);
PasswordAuthenticator auth = new PasswordAuthenticator() {
public boolean authenticate(String string, String string1, ServerSession ss) {
return true;
}
};
sshd.setPasswordAuthenticator(auth);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
sshd.start();
以下是我尝试连接服务器时的结果:
134 [com.ssh.Startup.main()] INFO org.apache.sshd.common.util.SecurityUtils - Trying to register BouncyCastle as a JCE provider
454 [com.ssh.Startup.main()] INFO org.apache.sshd.common.util.SecurityUtils - Registration succeeded
3845 [NioProcessor-2] INFO org.apache.sshd.server.session.ServerSession - Session created from /127.0.0.1:50426
3879 [NioProcessor-2] WARN org.apache.mina.core.filterchain.DefaultIoFilterChain - Unexpected exception from exceptionCaught handler.
java.lang.IllegalStateException: No session available
at org.apache.sshd.common.AbstractSessionIoHandler.exceptionCaught(AbstractSessionIoHandler.java:52)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.exceptionCaught(DefaultIoFilterChain.java:697)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextExceptionCaught(DefaultIoFilterChain.java:483)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1100(DefaultIoFilterChain.java:46)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.exceptionCaught(DefaultIoFilterChain.java:791)
at org.apache.mina.core.filterchain.IoFilterAdapter.exceptionCaught(IoFilterAdapter.java:111)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextExceptionCaught(DefaultIoFilterChain.java:483)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireExceptionCaught(DefaultIoFilterChain.java:471)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:359)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$700(DefaultIoFilterChain.java:46)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionCreated(DefaultIoFilterChain.java:771)
at org.apache.mina.core.filterchain.IoFilterAdapter.sessionCreated(IoFilterAdapter.java:79)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:357)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireSessionCreated(DefaultIoFilterChain.java:350)
at org.apache.mina.core.service.IoServiceListenerSupport.fireSessionCreated(IoServiceListenerSupport.java:211)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.addNow(AbstractPollingIoProcessor.java:521)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.handleNewSessions(AbstractPollingIoProcessor.java:488)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:67)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1103)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoSuchMethodError: org.slf4j.Logger.isTraceEnabled()Z
at org.apache.sshd.common.session.AbstractSession.encode(AbstractSession.java:436)
at org.apache.sshd.common.session.AbstractSession.writePacket(AbstractSession.java:349)
at org.apache.sshd.common.session.AbstractSession.sendKexInit(AbstractSession.java:693)
at org.apache.sshd.server.session.ServerSession.sendKexInit(ServerSession.java:336)
at org.apache.sshd.server.session.ServerSession.<init>(ServerSession.java:92)
at org.apache.sshd.server.session.SessionFactory.doCreateSession(SessionFactory.java:43)
at org.apache.sshd.common.session.AbstractSessionFactory.createSession(AbstractSessionFactory.java:38)
at org.apache.sshd.common.AbstractSessionIoHandler.sessionCreated(AbstractSessionIoHandler.java:37)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionCreated(DefaultIoFilterChain.java:643)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:357)
... 14 more
知道服务器可能出现什么问题吗?感谢所有帮助!
答案 0 :(得分:1)
您的类路径中似乎有一个不兼容的SLF4J版本:
Caused by: java.lang.NoSuchMethodError: org.slf4j.Logger.isTraceEnabled()Z