Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
1.7k views
in Java FTP by (270 points)
I am using edtFTPj/PRO v4.5.0 in a WebLogic 10.0 application server, which is only certified for Java 5. I have a thin wrapper class that extends SecureFileTransferClient. My user made a mistake and called setServerValidationEnabled(true) but never called getAdvancedSSHSettings().getSSHServerValidator().addKnownHost(server, path). As could be expected, the connection failed. What was unexpected though was this exception:

E:\Test>C:\PF64\Java\jdk1.5.0_16\bin\java -cp ".;edtftpj-pro.jar;license.jar" FtpClient
INFO: OPEN scsapq27.mydomain.com:22 using edtFTPj/PRO 4.5.0
ERROR: Unable to connect to SFTP server scsapq27.mydomain.com
ERROR: com.enterprisedt.net.ftp.FTPException: java.io.IOException: method <init>(Ljava/lang/String;Ljava/lang/Throwable;)V not found

That constructor for java.io.IOException was introduced in Java 6, which is why the "method not found" exception is being thrown. When I run the exact same code against edtFTPj/PRO v4.2.0 I get a much nicer exception:

E:\Test>C:\PF64\Java\jdk1.5.0_16\bin\java -cp ".;edtftpj-pro.jar;license.jar" FtpClient
INFO: OPEN scsapq27.mydomain.com:22 using edtFTPj/PRO 4.2.0
ERROR: Caught IOException connecting to SFTP server scsapq27.mydomain.com
ERROR: com.enterprisedt.net.j2ssh.transport.kex.KeyExchangeException: The host signature is invalid or the host key was not accepted!

The release history for edtFTPj/PRO does not mention that support for Java 5 has been dropped. Was this intended? I'd like to use the latest version of the product that still runs under Java 5. Is that 4.2.0? If it's 4.3.0 or 4.4.0 can someone post download links?

3 Answers

0 votes
by (161k points)
It's not intentional. If you post the stack trace that may tell us more about where the exception originates.
0 votes
by (270 points)
Thanks for the prompt reply! This is with the 4.6.1 JAR.

E:\Test>C:\PF64\Java\jdk1.5.0_16\bin\java -cp ".;edtftpj-pro.4.6.1.jar;license.jar" FtpClient
INFO: OPEN scsapq27.mydomain.com:22 using edtFTPj/PRO 4.6.1
ERROR: Unable to connect to SFTP server scsapq27.mydomain.com
com.enterprisedt.net.ftp.FTPException: java.io.IOException: method <init>(Ljava/lang/String;Ljava/lang/Throwable;)V not found
at com.enterprisedt.net.ftp.async.AsyncResult.endAsyncInternal(AsyncResult.java:315)
at com.enterprisedt.net.ftp.async.ConnectResult.endAsync(ConnectResult.java:116)
at com.enterprisedt.net.ftp.SecureFileTransferClient.connect(SecureFileTransferClient.java:765)
at FtpClient.connect(FtpClient.java:71)
at FtpClient.main(FtpClient.java:139)
0 votes
by (270 points)
I thought you might like to have a minimal use case that will trigger the exception:

import com.enterprisedt.net.ftp.SecureFileTransferClient;

public class FtpClient {
    public static void main( final String[] args ) throws com.enterprisedt.net.ftp.FTPException, java.io.IOException {
        final SecureFileTransferClient client = new SecureFileTransferClient(1, 1);
        client.setProtocol( com.enterprisedt.net.ftp.Protocol.SFTP );
        client.getAdvancedSSHSettings().setAuthenticationType( com.enterprisedt.net.ftp.ssh.SSHAuthenticationType.PASSWORD );

        // This triggers the Java 6 flavor IOException... failing to do the following call
        // client.getAdvancedSSHSettings().getSSHServerValidator().addKnownHost( server, file.getAbsolutePath() );

        client.setServerValidationEnabled( true );
        client.getAdvancedFTPSettings().setConnectMode( com.enterprisedt.net.ftp.FTPConnectMode.PASV );
        client.setRemoteHost( "scsapq27.mydomain.com" );
        client.setRemotePort( 22 );
        client.setUserName( "myusername" );
        client.setPassword( "mypassword" );
        client.connect();
    }
}


The above, when run under Java 5, generates the following exception:

E:\Berny\Test>C:\PF64\Java\jdk1.5.0_16\bin\java -cp ".;edtftpj-pro.4.6.1.jar;license.jar" FtpClient
Exception in thread "main" com.enterprisedt.net.ftp.FTPException: java.io.IOException: method <init>(Ljava/lang/String;Ljava/lang/Throwable;)V not found
        at com.enterprisedt.net.ftp.async.AsyncResult.endAsyncInternal(AsyncResult.java:315)
        at com.enterprisedt.net.ftp.async.ConnectResult.endAsync(ConnectResult.java:116)
        at com.enterprisedt.net.ftp.SecureFileTransferClient.connect(SecureFileTransferClient.java:765)
        at FtpClient.main(FtpClient.java:18)

Categories

...