Java JSchException找不到消息

Java JSchException找不到消息,java,sftp,jsch,Java,Sftp,Jsch,我想知道可能导致以下异常的一些原因。我找不到此消息在jsch-0.1.54.jar中找不到消息。存在一些直截了当的消息,如未找到文件和其他有意义的消息。但我需要更多关于这一点的信息,这样我才能找到根本原因 SftpException while running get ---> 2: Cannot find message [/destination/file.txt] at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.

我想知道可能导致以下异常的一些原因。我找不到此消息在jsch-0.1.54.jar中找不到消息。存在一些直截了当的消息,如未找到文件和其他有意义的消息。但我需要更多关于这一点的信息,这样我才能找到根本原因

SftpException while running get ---> 2: Cannot find message [/destination/file.txt]
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2289)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1741)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1758)
at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:786)
at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:750)
at com.iyi.ftp.SFTP.get(SFTP.java:99)
这是我的呼叫方法

public boolean get(final String remoteFile, final String localFile) throws JSchException {
    Vector connection = null;
    Session session = null;
    ChannelSftp c = null;
    boolean status = false;
    try {
        connection = this.connect();
        session = connection.get(0);
        c = connection.get(1);
        c.get(remoteFile, localFile);
        status = true;
    }
    catch (JSchException e) {
        SFTP.LGR.warn((Object)("JSchException in SFTP::get() ---> " + FTPFactory.getStackTrace((Throwable)e)));
        throw e;
    }
    catch (SftpException e2) {
        SFTP.LGR.warn((Object)("SftpException while running get ---> " + FTPFactory.getStackTrace((Throwable)e2)));
        throw new JSchException(e2.getMessage());
    }
    catch (CredentialDecryptionException e3) {
        SFTP.LGR.error((Object)"##CredentialDecryptionException##", (Throwable)e3);
        throw new JSchException(e3.getMessage(), (Throwable)e3);
    }
    finally {
        if (c != null) {
            c.quit();
        }
        if (session != null) {
            session.disconnect();
        }
    }
    if (c != null) {
        c.quit();
    }
    if (session != null) {
        session.disconnect();
    }
    return status;
}
这些方法取自jsch-0.1.54.jar,它是一个开源实用程序

public void get(String src, String dst, final SftpProgressMonitor monitor, final int mode) throws SftpException {
    boolean _dstExist = false;
    String _dst = null;
    try {
        ((MyPipedInputStream)this.io_in).updateReadSide();
        src = this.remoteAbsolutePath(src);
        dst = this.localAbsolutePath(dst);
        final Vector v = this.glob_remote(src);
        final int vsize = v.size();
        if (vsize == 0) {
            throw new SftpException(2, "No such file");
        }
        final File dstFile = new File(dst);
        final boolean isDstDir = dstFile.isDirectory();
        StringBuffer dstsb = null;
        if (isDstDir) {
            if (!dst.endsWith(ChannelSftp.file_separator)) {
                dst += ChannelSftp.file_separator;
            }
            dstsb = new StringBuffer(dst);
        }
        else if (vsize > 1) {
            throw new SftpException(4, "Copying multiple files, but destination is missing or a file.");
        }
        for (int j = 0; j < vsize; ++j) {
            final String _src = v.elementAt(j);
            final SftpATTRS attr = this._stat(_src);
            if (attr.isDir()) {
                throw new SftpException(4, "not supported to get directory " + _src);
            }
            _dst = null;
            if (isDstDir) {
                final int i = _src.lastIndexOf(47);
                if (i == -1) {
                    dstsb.append(_src);
                }
                else {
                    dstsb.append(_src.substring(i + 1));
                }
                _dst = dstsb.toString();
                if (_dst.indexOf("..") != -1) {
                    final String dstc = new File(dst).getCanonicalPath();
                    final String _dstc = new File(_dst).getCanonicalPath();
                    if (_dstc.length() <= dstc.length() || !_dstc.substring(0, dstc.length() + 1).equals(dstc + ChannelSftp.file_separator)) {
                        throw new SftpException(4, "writing to an unexpected file " + _src);
                    }
                }
                dstsb.delete(dst.length(), _dst.length());
            }
            else {
                _dst = dst;
            }
            final File _dstFile = new File(_dst);
            if (mode == 1) {
                final long size_of_src = attr.getSize();
                final long size_of_dst = _dstFile.length();
                if (size_of_dst > size_of_src) {
                    throw new SftpException(4, "failed to resume for " + _dst);
                }
                if (size_of_dst == size_of_src) {
                    return;
                }
            }
            if (monitor != null) {
                monitor.init(1, _src, _dst, attr.getSize());
                if (mode == 1) {
                    monitor.count(_dstFile.length());
                }
            }
            FileOutputStream fos = null;
            _dstExist = _dstFile.exists();
            try {
                if (mode == 0) {
                    fos = new FileOutputStream(_dst);
                }
                else {
                    fos = new FileOutputStream(_dst, true);
                }
                this._get(_src, fos, monitor, mode, new File(_dst).length());
            }
            finally {
                if (fos != null) {
                    fos.close();
                }
            }
        }
    }
    catch (Exception e) {
        if (!_dstExist && _dst != null) {
            final File _dstFile2 = new File(_dst);
            if (_dstFile2.exists() && _dstFile2.length() == 0L) {
                _dstFile2.delete();
            }
        }
        if (e instanceof SftpException) {
            throw (SftpException)e;
        }
        if (e instanceof Throwable) {
            throw new SftpException(4, "", e);
        }
        throw new SftpException(4, "");
    }
}

private SftpATTRS _stat(final byte[] path) throws SftpException {
    try {
        this.sendSTAT(path);
        Header header = new Header();
        header = this.header(this.buf, header);
        final int length = header.length;
        final int type = header.type;
        this.fill(this.buf, length);
        if (type != 105) {
            if (type == 101) {
                final int i = this.buf.getInt();
                this.throwStatusError(this.buf, i);
            }
            throw new SftpException(4, "");
        }
        final SftpATTRS attr = SftpATTRS.getATTR(this.buf);
        return attr;
    }
    catch (Exception e) {
        if (e instanceof SftpException) {
            throw (SftpException)e;
        }
        if (e instanceof Throwable) {
            throw new SftpException(4, "", e);
        }
        throw new SftpException(4, "");
    }
}

错误消息来自您的服务器。这确实是一条非常奇怪的消息,但我假设是某个自定义SFTP服务器处理一些消息,而不是普通文件

因此,该消息基本上转化为无法找到传统SFTP服务器的文件错误。甚至错误代码2 SSH\u FX\u NO\u这样的文件也支持这一点


您在remoteFile中的路径可能是错误的。

特定jar中的这个get方法需要4个参数,而您只传递了2个作为参数argument@NitinSinghal是的,还有其他的包装器方法将控制权传递给这个方法,不必提及它们。此外,问题与参数的数量无关。您是否检查了connection、session和channelSftp对象是否具有正确的值?