Alfred’s Computing Weblog

Alfred Java-cored Computing Weblog

Posts Tagged ‘commons-net

Ant | NoClassDefFoundError + MalformedServerReplyException

with 3 comments

Could not create type ftp due to java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClientConfig

I trying to do ftp via apache ant’s target.
I get the above error as I tried to execute the ant-ftp target with default ant (v.1.7.1) package.
From the error message, its stated clear that there is missing of class named FTPClientConfig under package org.apache.commons.net.ftp.
Therefore, the first comes to my mind is I’m missing the JAR file that contains mentioned class file.
I quickly google and download the latest commons-net and place the JAR files into Ant’s lib folder (../apache-ant-1.7.1/lib/).

Wow.. The problem solved by putting the commons net JAR into Ant’s Lib folder.
But, yet another error comes out. Another problem solving process begin…

========================================================

error during FTP transfer: org.apache.commons.net.MalformedServerReplyException:
Could not parse response code. Server Reply: SSH-1.99-OpenSSH_3.9p1

I have no idea what this error message talking about.
From a quick googled, I know that the error message is meaning the remote host is expecting SSH instead of FTP.
It looks strange because I’m trying to do FTP, not SSH. So, I double the probably root couse, which is the ant xml

.....
<target name="ftp-test">
    <ftp server="${remote.host.ip}"
         port="22"
         remotedir="${remote.host.target.dir}"
         userid="${remote.host.userid}"
         password="${remote.host.password}"
         passive="yes"
         depends="yes"
         binary="yes">
        <fileset dir="${jar.dir}/${ant.project.name}.jar">
            <include name="**/*.jar"/>
        </fileset>
    </ftp>
</target>
.....

I tried to double check every variables, and I did not find any doubtful stuff.
By looking again and again, then only I see the doubtful configuration — port.
The port 22 is default port for SSH! I think this is the main reason commons-net expecting SSH from me.
I change the port to 21 (default FTP port) and test again.

Yet, another error message shown. The mission continue… 🙂

Advertisements

Written by Alfred

February 17, 2009 at 16:59