Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.8k views
in Java FTP by (200 points)
Version: edtFTPjPRO-3.4.1.
JavaEE server: weblogic 10.3.4
SFTP server: tried freeFTPd and Cerberus FTP Server (both have problem)
Protocol: SFTP

Situation:
We are facing some technical problem when running SSHFTPClient to connect SFTP server with edtFTPjPRO-3.4.1. The Transport Protocol thread failed : com.enterprisedt.cryptix.provider.elgamal.BaseElGamalKeyPairGenerator java.lang.ClassCastException: com.enterprisedt.cryptix.provider.elgamal.BaseElGamalKeyPairGenerator
....
... is recorded in the DEBUG log.

We have a program using edtFTPjPRO for SFTP file transfer. Recently, we found that the program cannot transfer file to the SFTP server after several requests.
Usually, we found the problem may not occur at the very beginning. However, the problem occur after several request (actually, we are just repeating to upload the same file to same SFTP server).

Below is the code of the program:
public class EdtSFtp {
   
    static{
        License.setLicenseDetails(EDT_LICENSE_OWNER, EDT_LICENSE_KEY);
    }
    
    private SSHFTPClient sftp = new SSHFTPClient();
    
    public void connectAndLogin(String hostname, String username, String password) throws FTPException,IOException {

        sftp.setRemoteHost(hostname);
        sftp.setAuthentication(username, password);
        sftp.getValidator().setHostValidationEnabled(false);
        sftp.connect();
       // sftp.setType(FTPTransferType.BINARY);
    }
    
    public void setTimeout(int milliSec) throws FTPException {
        sftp.setTimeout(milliSec);
    }
    
    public void setBinary(){
        sftp.setType(FTPTransferType.BINARY);
    }
    
    public void setAscii(){
        sftp.setType(FTPTransferType.ASCII);
    }
    
    
    public void disconnect() throws IOException, FTPException { 
        sftp.quit();
    }
    
    public void uploadStream(byte[] data, String path, String remoteFile) throws FTPException, IOException  {
    
        if (!(path == null || path.equals(""))){
            changeDir(path);
        }

        sftp.put(data, remoteFile);

    }    
    
    public void downloadStream(OutputStream out, String path, String remoteFile) throws IOException, FTPException {
        
        if (!(path == null || path.equals(""))){
            changeDir(path);
        }
       
        sftp.get(out, remoteFile);
    }   
    
    public boolean isConnected(){
        return sftp.connected();
    }
    
    private void changeDir(String path) throws IOException, FTPException {
        
        try {
            sftp.chdir(path);
        }  catch (FTPException e) {
            sftp.mkdir(path);
            sftp.chdir(path);
        }      
    }
}

public class ReportExporter {
 
    public void exportFile(byte[] content, String username, String outHost, String outPath, String outFileName) throws Exception{

          try {
             EdtSFtp sftp = new EdtSFtp();
             sftp.setTimeout(sftpTimeout);
              sftp.connectAndLogin(outHost, accountUsername, accountPassword);
              sftp.setBinary();
              sftp.uploadStream(content, outPath, outFileName);
          }
          catch (FTPException fe){
                      //...
          }
          catch (IOException ie){
            //...
          }
          catch(Exception e){
          
          } 
          finally{
               
              if (sftp.isConnected()){
                  try{
                      sftp.disconnect();
                  } catch(IOException e){
                      //for server with auto disconnect
                      e.printStackTrace();
                  } catch(FTPException e){
                      //for server with auto disconnect
                      e.printStackTrace();
                  }
              }
          }
      }
}


Below is the connection log of Cerberus FTP server when the problem occur:
2011/10/21 16:05:34 [10] Incoming connection request on SSH interface 2 at 160.78.18.136
2011/10/21 16:05:34 [10] SSH FTP connection request accepted from 160.84.67.95
2011/10/21 16:05:34 [10] Client Identification: SSH-2.0-edtFTPjPRO-3.4.1
2011/10/21 16:05:34 [10] Algorithm negotiation complete: Proceeding with key exchange
2011/10/21 16:05:34 [10] Kex: 'diffie-hellman-group1-sha1' Host Key: 'ssh-rsa' C2S : '3des-cbc, hmac-sha1, none' S2C : '3des-cbc, hmac-sha1, none'
2011/10/21 16:05:34 [10] The client closed the connection
2011/10/21 16:05:34 [10] Connection terminated

Here is the DEBUG log of the edtFTPjPRO-3.4.1:
INFO [LicensePropertiesBase] 21 Oct 2011 16:57:35.414 : Licence expiry date: 31 Dec 9999
INFO [LicensePropertiesBase] 21 Oct 2011 16:57:35.414 : Production licence
DEBUG [SCPClient] 21 Oct 2011 16:57:35.414 : Class: com.enterprisedt.net.ft

3 Answers

0 votes
by (162k points)
There's been quite a few changes since 3.4.1. It is worthwhile upgrading to 3.9.1 and seeing if the problem is still there.
0 votes
by (200 points)
Problem still persisted in 3.9.1

Here is the debug log:
INFO [SCPClient] 24 Oct 2011 10:47:00.321 : SCPClient settings validated.
DEBUG [SCPClient] 24 Oct 2011 10:47:00.321 : Connecting to sa1-cst548-01:22
DEBUG [StreamSocketFactory] 24 Oct 2011 10:47:00.321 : Connecting to sa1-cst548-01:22 via standard socket
INFO [TransportProtocolCommon] 24 Oct 2011 10:47:00.321 : Timeout=60000
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.321 : Starting transport protocol
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.322 : Registering transport protocol messages with inputstream
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.322 : Negotiating protocol version
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.322 : Local identification: SSH-2.0-edtFTPjPRO-3.9.1
INFO [TransportProtocolCommon] 24 Oct 2011 10:47:00.322 : Wait for state update timeout=60000
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Read: 'SSH-2.0-WeOnlyDo-wodFTPD 2.3.6.165
'
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : EOL is guessed at CR+LF
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Remote identification: 'SSH-2.0-WeOnlyDo-wodFTPD 2.3.6.165'
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Protocol negotiation complete
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Name=SSH_MSG_KEX_INIT,MessageId=20
Supported Kex diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
Supported Public Keys ssh-dss,ssh-rsa
Supported Encryption Client->Server blowfish-cbc,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc,arcfour
Supported Encryption Server->Client blowfish-cbc,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc,arcfour
Supported Mac Client->Server hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-md5
Supported Mac Server->Client hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-md5
Supported Compression Client->Server none,zlib
Supported Compression Server->Client none,zlib
Supported Languages Client->Server
Supported Languages Server->Client
First Kex Packet Follows [FALSE]
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Sending SSH_MSG_KEX_INIT
INFO [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Wait for state update timeout=60000
DEBUG [SshMsgKexInit] 24 Oct 2011 10:47:00.328 : Packetlength=428, Paddinglength=8
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Received registered message: SSH_MSG_KEX_INIT
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Received Name=SSH_MSG_KEX_INIT,MessageId=20
Supported Kex diffie-hellman-group1-sha1
Supported Public Keys ssh-rsa
Supported Encryption Client->Server aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc@lysator.liu.se
Supported Encryption Server->Client aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc@lysator.liu.se
Supported Mac Client->Server hmac-sha1,hmac-md5,none
Supported Mac Server->Client hmac-sha1,hmac-md5,none
Supported Compression Client->Server zlib,none
Supported Compression Server->Client zlib,none
Supported Languages Client->Server
Supported Languages Server->Client
First Kex Packet Follows [FALSE]
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Starting key exchange
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Determine Algorithm
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Client Algorithms: [diffie-hellman-group1-sha1, diffie-hellman-group-exchange-sha1]
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Server Algorithms: [diffie-hellman-group1-sha1]
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Returning diffie-hellman-group1-sha1
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : Key exchange algorithm: diffie-hellman-group1-sha1
INFO [DhGroup1Sha1] 24 Oct 2011 10:47:00.328 : Starting client side key exchange.
WARN [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : The Transport Protocol thread failed: com.enterprisedt.cryptix.provider.elgamal.BaseElGamalKeyPairGenerator
DEBUG [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : stop() called
INFO [TransportProtocolCommon] 24 Oct 2011 10:47:00.328 : The Transport Protocol has been stopped
0 votes
by (162k points)
Is it possible that you have two copies of edtftpj-pro.jar available in Weblogic? It has the look of a class being loaded by different classloaders.

Categories

...