Java com.jcraft.jsch.ChannelSftp.throwstatus错误

Java com.jcraft.jsch.ChannelSftp.throwstatus错误,java,file-permissions,jsch,Java,File Permissions,Jsch,我试图在其中创建一个文件夹(folderName)和两个文件(file1.txt,file2.txt)。创建文件夹和文件后,我更新其权限。首先更新文件的权限,然后更新文件夹的权限。但当调用文件夹权限进行更新时,引发异常。即使引发异常,也会正确更新文件夹和文件的权限。请帮助我找到如何防止此异常 更新1: channelSftp.chmod(511,文件夹)//注释此行,正常工作,但无法更新文件夹的权限 更新2: channelSftp.chmod(511,文件夹)//即使删除所有行并使用文件夹创建

我试图在其中创建一个
文件夹(folderName)和两个文件(file1.txt,file2.txt)
。创建文件夹和文件后,我更新其权限。首先更新文件的权限,然后更新文件夹的权限。但当调用文件夹权限进行更新时,引发异常。即使引发异常,也会正确更新文件夹和文件的权限。请帮助我找到如何防止此异常

更新1:
channelSftp.chmod(511,文件夹)//注释此行,正常工作,但无法更新文件夹的权限

更新2:
channelSftp.chmod(511,文件夹)//即使删除所有行并使用文件夹创建代码保留这一行,这一行仍然存在问题。文件夹已创建,但权限更新后出现异常

WinSCP屏幕:

代码:

        String depDir = "/BaicDirectory";
        System.out.println("Processing ........ starts");

        Session session = new FTPComponent().getSession("");
        Channel channel = null;
        ChannelSftp channelSftp = null;
        try
        {
            session.connect();
            System.out.println("session is alive:" + session.isConnected());
            channel = session.openChannel("sftp");
            channel.connect();
            channelSftp = (ChannelSftp) channel;
            InputStream ftpLogIStream = new ByteArrayInputStream("file1.txt content".getBytes());
            InputStream processLogIStream = new ByteArrayInputStream("file2.txt content".getBytes());
            channelSftp.cd(depDir);
            String folder = "folderName";
            channelSftp.mkdir(folder);
            System.out.println("Folder is created");
            channelSftp.put(ftpLogIStream, depDir + "/" + folder + "/file1.txt");
            channelSftp.put(processLogIStream, depDir + "/" + folder + "/file2.txt");
            System.out.println("Files are created");
            channelSftp.cd(depDir + "/" + folder);
            channelSftp.chmod(511, "file1.txt");
            channelSftp.chmod(511, "file2.txt");
            System.out.println("Files permissons are updated");
            channelSftp.cd(depDir);
            System.out.println("Directory to main location");
输出:

Processing ........ starts
session is alive:true
Folder is created
Files is created
Files permissons are updated
Directory to main location
session is alive:true
Failure
        at com.jcraft.jsch.ChannelSftp.throwStatusError(Unknown Source)
        at com.jcraft.jsch.ChannelSftp._setStat(Unknown Source)
        at com.jcraft.jsch.ChannelSftp.chmod(Unknown Source)
        at com.app.sftp.CLOWriteBack.main(CLOWriteBack.java:747)
After all statements ........ ends
更新3:WinSCP会话调试1日志

. 2015-11-23 03:06:04.555 Changing properties of "folderName" (No)
. 2015-11-23 03:06:04.555  - mode: "u+rwx-s,g+rwx-s,o+rwx-t"
> 2015-11-23 03:06:04.556 Type: SSH_FXP_LSTAT, Size: 91, Number: 10759
. 2015-11-23 03:06:04.556 Sent 95 bytes
. 2015-11-23 03:06:04.556 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.556 Read 4 bytes (24 pending)
. 2015-11-23 03:06:04.556 Read 24 bytes (0 pending)
< 2015-11-23 03:06:04.556 Type: SSH_FXP_STATUS, Size: 24, Number: 10500
. 2015-11-23 03:06:04.556 Discarding reserved response
. 2015-11-23 03:06:04.556 Waiting for another 4 bytes
. 2015-11-23 03:06:04.557 Detected network event
. 2015-11-23 03:06:04.557 Received 41 bytes (0)
. 2015-11-23 03:06:04.557 Read 4 bytes (37 pending)
. 2015-11-23 03:06:04.557 Read 37 bytes (0 pending)
< 2015-11-23 03:06:04.557 Type: SSH_FXP_ATTRS, Size: 37, Number: 10759
> 2015-11-23 03:06:04.557 Type: SSH_FXP_SETSTAT, Size: 99, Number: 11017
. 2015-11-23 03:06:04.557 Sent 103 bytes
. 2015-11-23 03:06:04.557 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.557 Waiting for another 4 bytes
. 2015-11-23 03:06:04.558 Detected network event
. 2015-11-23 03:06:04.558 Received 28 bytes (0)
. 2015-11-23 03:06:04.558 Read 4 bytes (24 pending)
. 2015-11-23 03:06:04.558 Read 24 bytes (0 pending)
< 2015-11-23 03:06:04.558 Type: SSH_FXP_STATUS, Size: 24, Number: 11017
< 2015-11-23 03:06:04.558 Status code: 0
. 2015-11-23 03:06:04.559 Listing directory "/BaicDirectory".
> 2015-11-23 03:06:04.559 Type: SSH_FXP_OPENDIR, Size: 80, Number: 11275
. 2015-11-23 03:06:04.559 Sent 84 bytes
. 2015-11-23 03:06:04.559 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.559 Waiting for another 4 bytes
. 2015-11-23 03:06:04.560 Detected network event
. 2015-11-23 03:06:04.560 Received 17 bytes (0)
. 2015-11-23 03:06:04.560 Read 4 bytes (13 pending)
. 2015-11-23 03:06:04.560 Read 13 bytes (0 pending)
< 2015-11-23 03:06:04.560 Type: SSH_FXP_HANDLE, Size: 13, Number: 11275
> 2015-11-23 03:06:04.560 Type: SSH_FXP_READDIR, Size: 13, Number: 11532
. 2015-11-23 03:06:04.560 Sent 17 bytes
. 2015-11-23 03:06:04.560 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.560 Waiting for another 4 bytes
. 2015-11-23 03:06:04.561 Detected network event
. 2015-11-23 03:06:04.561 Received 327 bytes (0)
. 2015-11-23 03:06:04.561 Read 4 bytes (323 pending)
. 2015-11-23 03:06:04.561 Read 323 bytes (0 pending)
< 2015-11-23 03:06:04.561 Type: SSH_FXP_NAME, Size: 323, Number: 11532
> 2015-11-23 03:06:04.561 Type: SSH_FXP_READDIR, Size: 13, Number: 11788
. 2015-11-23 03:06:04.561 Sent 17 bytes
. 2015-11-23 03:06:04.561 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.561 Read file '.' from listing
. 2015-11-23 03:06:04.562 Read file '..' from listing
. 2015-11-23 03:06:04.562 Read file 'folderName' from listing
. 2015-11-23 03:06:04.562 Waiting for another 4 bytes
. 2015-11-23 03:06:04.562 Detected network event
. 2015-11-23 03:06:04.562 Received 32 bytes (0)
. 2015-11-23 03:06:04.562 Read 4 bytes (28 pending)
. 2015-11-23 03:06:04.562 Read 28 bytes (0 pending)
< 2015-11-23 03:06:04.562 Type: SSH_FXP_STATUS, Size: 28, Number: 11788
< 2015-11-23 03:06:04.562 Status code: 1
> 2015-11-23 03:06:04.562 Type: SSH_FXP_CLOSE, Size: 13, Number: 12036
. 2015-11-23 03:06:04.562 Sent 17 bytes
. 2015-11-23 03:06:04.562 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.562 ..;d;1024;2015-11-20T13:34:34.000Z;"useracid" [24416];"useracid" [8481];rwxrwxrwx;1
. 2015-11-23 03:06:04.562 folderName;d;96;2015-11-21T08:47:52.000Z;"useracid" [24416];"useracid" [8481];rwxrwxrwx;1
. 2015-11-23 03:06:04.573 Session upkeep
. 2015-11-23 03:06:04.573 Detected network event
. 2015-11-23 03:06:04.573 Received 28 bytes (0)
. 2015-11-23 03:06:05.025 Session upkeep
。2015-11-23 03:06:04.555更改“folderName”(编号)的属性
. 2015-11-23 03:06:04.555-模式:“u+rwx-s,g+rwx-s,o+rwx-t”
>2015-11-23 03:06:04.556型号:SSH_fxplstat尺码:91号码:10759
. 2015-11-23 03:06:04.556发送了95字节
. 2015-11-23 03:06:04.556发送缓冲区中还有0个字节
. 2015-11-23 03:06:04.556读取4个字节(24个待定)
. 2015-11-23 03:06:04.556读取24字节(0待定)
<2015-11-23 03:06:04.556类型:SSH\U FXP\U状态,大小:24,编号:10500
. 2015-11-23 03:06:04.556丢弃保留响应
. 2015-11-23 03:06:04.556正在等待另一个4字节
. 2015-11-23 03:06:04.557检测到网络事件
. 2015-11-23 03:06:04.557接收到41字节(0)
. 2015-11-23 03:06:04.557读取4个字节(37个待定)
. 2015-11-23 03:06:04.557读取37字节(0待定)
<2015-11-23 03:06:04.557类型:SSH\u FXP\u属性,大小:37,编号:10759
>2015-11-23 03:06:04.557类型:SSH_FXP_SETSTAT,大小:99,编号:11017
. 2015-11-23 03:06:04.557发送103字节
. 2015-11-23 03:06:04.557发送缓冲区中还有0个字节
. 2015-11-23 03:06:04.557正在等待另一个4字节
. 2015-11-23 03:06:04.558检测到网络事件
. 2015-11-23 03:06:04.558接收到28字节(0)
. 2015-11-23 03:06:04.558读取4个字节(24个待定)
. 2015-11-23 03:06:04.558读取24字节(0待定)
<2015-11-23 03:06:04.558类型:SSH\U FXP\U状态,大小:24,编号:11017
<2015-11-23 03:06:04.558状态代码:0
. 2015-11-23 03:06:04.559列出目录“/目录”。
>2015-11-23 03:06:04.559类型:SSH_FXP_OPENDIR,大小:80,号码:11275
. 2015-11-23 03:06:04.559发送了84字节
. 2015-11-23 03:06:04.559发送缓冲区中还有0个字节
. 2015-11-23 03:06:04.559正在等待另一个4字节
. 2015-11-23 03:06:04.560检测到网络事件
. 2015-11-23 03:06:04.560接收到17个字节(0)
. 2015-11-23 03:06:04.560读取4个字节(13个待定)
. 2015-11-23 03:06:04.560读取13字节(0待定)
<2015-11-23 03:06:04.560类型:SSH\U FXP\U手柄,尺寸:13,编号:11275
>2015-11-23 03:06:04.560类型:SSH_FXP_READDIR,大小:13,号码:11532
. 2015-11-23 03:06:04.560发送了17个字节
. 2015-11-23 03:06:04.560发送缓冲区中还有0个字节
. 2015-11-23 03:06:04.560正在等待另一个4字节
. 2015-11-23 03:06:04.561检测到网络事件
. 2015-11-23 03:06:04.561接收到327字节(0)
. 2015-11-23 03:06:04.561读取4字节(323待定)
. 2015-11-23 03:06:04.561读取323字节(0待定)
<2015-11-23 03:06:04.561类型:SSH_FXP_名称,大小:323,号码:11532
>2015-11-23 03:06:04.561型号:SSH_FXP_READDIR,尺码:13,号码:11788
. 2015-11-23 03:06:04.561发送了17个字节
. 2015-11-23 03:06:04.561发送缓冲区中还有0个字节
. 2015-11-23 03:06:04.561从列表中读取文件“.”
. 2015-11-23 03:06:04.562从列表中读取文件“..”
. 2015-11-23 03:06:04.562从列表中读取文件“folderName”
. 2015-11-23 03:06:04.562正在等待另一个4字节
. 2015-11-23 03:06:04.562检测到网络事件
. 2015-11-23 03:06:04.562接收到32字节(0)
. 2015-11-23 03:06:04.562读取4个字节(28个待定)
. 2015-11-23 03:06:04.562读取28字节(0待定)
<2015-11-23 03:06:04.562类型:SSH\U FXP\U状态,大小:28,编号:11788
<2015-11-23 03:06:04.562状态代码:1
>2015-11-23 03:06:04.562型号:SSH_FXP_CLOSE,尺码:13,号码:12036
. 2015-11-23 03:06:04.562发送了17个字节
. 2015-11-23 03:06:04.562发送缓冲区中还有0个字节
. 2015-11-23 03:06:04.562 ..;D1024;2015-11-20T13:34:34.000Z;“用户酸”[24416];“用户酸”[8481];rwxrwxrwx;1.
. 2015-11-23 03:06:04.562 folderName;D96;2015-11-21T08:47:52.000Z;“用户酸”[24416];“用户酸”[8481];rwxrwxrwx;1.
. 2015-11-23 03:06:04.573课时保养
. 2015-11-23 03:06:04.573检测到网络事件
. 2015-11-23 03:06:04.573接收到28字节(0)
. 2015-11-23 03:06:05.025课时保养

您可以在WinSCP中更改权限吗?使用相同的凭据,我可以毫无问题地更新权限。更改文件(file1.txt和file2.txt)的权限有效,对吗?在WinSCP中,您可以更改文件和文件夹的权限,对吗?是的,我可以这样做。
Processing ........ starts
session is alive:true
Folder is created
Files is created
Files permissons are updated
Directory to main location
session is alive:true
Failure
        at com.jcraft.jsch.ChannelSftp.throwStatusError(Unknown Source)
        at com.jcraft.jsch.ChannelSftp._setStat(Unknown Source)
        at com.jcraft.jsch.ChannelSftp.chmod(Unknown Source)
        at com.app.sftp.CLOWriteBack.main(CLOWriteBack.java:747)
After all statements ........ ends
. 2015-11-23 03:06:04.555 Changing properties of "folderName" (No)
. 2015-11-23 03:06:04.555  - mode: "u+rwx-s,g+rwx-s,o+rwx-t"
> 2015-11-23 03:06:04.556 Type: SSH_FXP_LSTAT, Size: 91, Number: 10759
. 2015-11-23 03:06:04.556 Sent 95 bytes
. 2015-11-23 03:06:04.556 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.556 Read 4 bytes (24 pending)
. 2015-11-23 03:06:04.556 Read 24 bytes (0 pending)
< 2015-11-23 03:06:04.556 Type: SSH_FXP_STATUS, Size: 24, Number: 10500
. 2015-11-23 03:06:04.556 Discarding reserved response
. 2015-11-23 03:06:04.556 Waiting for another 4 bytes
. 2015-11-23 03:06:04.557 Detected network event
. 2015-11-23 03:06:04.557 Received 41 bytes (0)
. 2015-11-23 03:06:04.557 Read 4 bytes (37 pending)
. 2015-11-23 03:06:04.557 Read 37 bytes (0 pending)
< 2015-11-23 03:06:04.557 Type: SSH_FXP_ATTRS, Size: 37, Number: 10759
> 2015-11-23 03:06:04.557 Type: SSH_FXP_SETSTAT, Size: 99, Number: 11017
. 2015-11-23 03:06:04.557 Sent 103 bytes
. 2015-11-23 03:06:04.557 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.557 Waiting for another 4 bytes
. 2015-11-23 03:06:04.558 Detected network event
. 2015-11-23 03:06:04.558 Received 28 bytes (0)
. 2015-11-23 03:06:04.558 Read 4 bytes (24 pending)
. 2015-11-23 03:06:04.558 Read 24 bytes (0 pending)
< 2015-11-23 03:06:04.558 Type: SSH_FXP_STATUS, Size: 24, Number: 11017
< 2015-11-23 03:06:04.558 Status code: 0
. 2015-11-23 03:06:04.559 Listing directory "/BaicDirectory".
> 2015-11-23 03:06:04.559 Type: SSH_FXP_OPENDIR, Size: 80, Number: 11275
. 2015-11-23 03:06:04.559 Sent 84 bytes
. 2015-11-23 03:06:04.559 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.559 Waiting for another 4 bytes
. 2015-11-23 03:06:04.560 Detected network event
. 2015-11-23 03:06:04.560 Received 17 bytes (0)
. 2015-11-23 03:06:04.560 Read 4 bytes (13 pending)
. 2015-11-23 03:06:04.560 Read 13 bytes (0 pending)
< 2015-11-23 03:06:04.560 Type: SSH_FXP_HANDLE, Size: 13, Number: 11275
> 2015-11-23 03:06:04.560 Type: SSH_FXP_READDIR, Size: 13, Number: 11532
. 2015-11-23 03:06:04.560 Sent 17 bytes
. 2015-11-23 03:06:04.560 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.560 Waiting for another 4 bytes
. 2015-11-23 03:06:04.561 Detected network event
. 2015-11-23 03:06:04.561 Received 327 bytes (0)
. 2015-11-23 03:06:04.561 Read 4 bytes (323 pending)
. 2015-11-23 03:06:04.561 Read 323 bytes (0 pending)
< 2015-11-23 03:06:04.561 Type: SSH_FXP_NAME, Size: 323, Number: 11532
> 2015-11-23 03:06:04.561 Type: SSH_FXP_READDIR, Size: 13, Number: 11788
. 2015-11-23 03:06:04.561 Sent 17 bytes
. 2015-11-23 03:06:04.561 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.561 Read file '.' from listing
. 2015-11-23 03:06:04.562 Read file '..' from listing
. 2015-11-23 03:06:04.562 Read file 'folderName' from listing
. 2015-11-23 03:06:04.562 Waiting for another 4 bytes
. 2015-11-23 03:06:04.562 Detected network event
. 2015-11-23 03:06:04.562 Received 32 bytes (0)
. 2015-11-23 03:06:04.562 Read 4 bytes (28 pending)
. 2015-11-23 03:06:04.562 Read 28 bytes (0 pending)
< 2015-11-23 03:06:04.562 Type: SSH_FXP_STATUS, Size: 28, Number: 11788
< 2015-11-23 03:06:04.562 Status code: 1
> 2015-11-23 03:06:04.562 Type: SSH_FXP_CLOSE, Size: 13, Number: 12036
. 2015-11-23 03:06:04.562 Sent 17 bytes
. 2015-11-23 03:06:04.562 There are 0 bytes remaining in the send buffer
. 2015-11-23 03:06:04.562 ..;d;1024;2015-11-20T13:34:34.000Z;"useracid" [24416];"useracid" [8481];rwxrwxrwx;1
. 2015-11-23 03:06:04.562 folderName;d;96;2015-11-21T08:47:52.000Z;"useracid" [24416];"useracid" [8481];rwxrwxrwx;1
. 2015-11-23 03:06:04.573 Session upkeep
. 2015-11-23 03:06:04.573 Detected network event
. 2015-11-23 03:06:04.573 Received 28 bytes (0)
. 2015-11-23 03:06:05.025 Session upkeep