Alfred’s Computing Weblog

Alfred Java-cored Computing Weblog

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… 🙂

Written by Alfred

February 17, 2009 at 16:59

3 Responses

Subscribe to comments with RSS.

  1. i am having the same problems, whatever happened?

    paul b.

    June 1, 2009 at 23:59

    • For my case, there is some network / firewall issue. The problem is solved by the help from some network guys in my company. 🙂

      Alfred

      June 2, 2009 at 9:59

  2. Two things… First, per the documentation for the FTP task, you need both ant-commons-net-X.X.jar (currently 2.0) and jakarta-oro-X.X.X.jar (currently 2.0.8).

    Here is the kicker though. 😦 I haven’t had any luck using a taskdef and then setting the classpath. That doesn’t seem to work. Therefore, you need to copy those two JARs into your ant’s /lib directory.

    There is one more kicker… My experience has been that the ant’s BIN directory *must* be on the system’s PATH. If it isn’t, then you’ll continue to get the ClassDefNotFound error.

    I can understand why taskdef might not work. I don’t understand why the path has to be set. That seems very un-Java-esque. 😦

    Alan

    May 4, 2010 at 2:17


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: