my aplication doesn't send file

2011-12-02
2013-05-20
  • clemilton baracho

    Hello, I am connecting an application to a proftpd server, but unfortunately I can not transmit a file completely, that is, the proftpd is only creating the file, but it can not insert the file data completely. and the following exception occurs:

    02/12/2011 10:26:14 com.sshtools.j2ssh.sftp.SftpSubsystemClient getOKRequestStatus
    INFO: Received response
    java.lang.NegativeArraySizeException
    at com.sshtools.j2ssh.sftp.SshFxpWrite.<init>(Unknown Source)
    at com.sshtools.j2ssh.sftp.SftpSubsystemClient.writeFile(Unknown Source)
    at com.sshtools.j2ssh.sftp.SftpFileOutputStream.write(Unknown Source)
    at com.sshtools.j2ssh.SftpClient.transferFile(Unknown Source)
    at com.sshtools.j2ssh.SftpClient.put(Unknown Source)
    at com.sshtools.j2ssh.SftpClient.put(Unknown Source)
    at com.sshtools.j2ssh.SftpClient.put(Unknown Source)
    at teste.TesteSsh2.<init>(TesteSsh2.java:34)
    at teste.TesteSsh2.main(TesteSsh2.java:63)

    It is noteworthy that on another server the code works perfectly, and other commands work well in the current server.
    does anyone know why this happening?

    my code:

    try {
                SshClient ssh = new SshClient();
                ssh.connect("10.10.200.17", 21);
                PasswordAuthenticationClient passwordAuthenticationClient = new PasswordAuthenticationClient();
                passwordAuthenticationClient.setUsername("teste");
                passwordAuthenticationClient.setPassword("teste");
                if (ssh.authenticate(passwordAuthenticationClient) != AuthenticationProtocolState.COMPLETE) {
                    throw new IOException("Login failed");
                }
                SftpClient client = ssh.openSftpClient();                       
                client.put("teste.iso","/teste2/");
                client.quit();
                System.out.println(""+client.pwd());
                ssh.disconnect();
            } catch (Exception e) {
                e.printStackTrace();
            }

    I thank

     
  • Pat

    Pat - 2011-12-02

    The server window size may be > a Java integer (2G). If so, in SftpFileOutputStream change -

    From:
    available = ((int) file.getSFTPSubsystem().availableWindowSpace() < max)
    ? (int) file.getSFTPSubsystem().availableWindowSpace() : max;

    To
    Long availableWindowSpace = new Long(file.getSFTPSubsystem().availableWindowSpace());
    available = (availableWindowSpace.compareTo(new Long(max)) < 0)
                    ? availableWindowSpace.intValue() : max;

     
  • Pat

    Pat - 2011-12-02

    When you rebuild j2ssh make sure you have debug on or diagnosing problems are difficult without line references like -
         at com.sshtools.j2ssh.sftp.SshFxpWrite.<init>(Unknown Source)

    Your build.xml file (or similar depending on how you rebuild) should have
      <property name="build.debugInformation" value="on"/>

     
  • clemilton baracho

    Ok! it's works, tks so much!

     

Log in to post a comment.