Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3982058
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:29:01+00:00 2026-05-20T05:29:01+00:00

i have a weird problem with my local Testing-Setup of a simple Java URL

  • 0

i have a weird problem with my local Testing-Setup of a simple Java URL FTP Connection.
Following code fragments (removed try/catches):

URL url = new URL("ftp://127.0.0.1/subOne/subTwo/subThree/subFour");
URLConnection conn = url.openConnection();
conn.setConnectTimeout(30000);
conn.setReadTimeout(30000);

InputStream is = conn.getInputStream(); /// And here flies the IOException!

… The actual IOException-Cause is “subOne/subTwo/subThree/subFour”, but the funny things happen on server side:

(000012)23.02.2011 13:01:05 - (not logged in) (127.0.0.1)> Connected, sending welcome message...
(000012)23.02.2011 13:01:05 - (not logged in) (127.0.0.1)> 220 Blabla
(000012)23.02.2011 13:01:05 - (not logged in) (127.0.0.1)> USER anonymous
(000012)23.02.2011 13:01:05 - (not logged in) (127.0.0.1)> 331 Password required for anonymous
(000012)23.02.2011 13:01:05 - (not logged in) (127.0.0.1)> PASS *************
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 230 Logged on
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> TYPE I
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 200 Type set to I
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> CWD das
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 250 CWD successful. "/subOne" is current directory.
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> CWD 2011
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 250 CWD successful. "/subOne/subTwo" is current directory.
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> CWD 02
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 250 CWD successful. "/subOne/subTwo/subThree" is current directory.
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> EPSV ALL
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 229 Entering Extended Passive Mode (|||3881|)
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> EPSV
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 229 Entering Extended Passive Mode (|||3882|)
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> RETR subFour
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 550 File not found
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> CWD subOne
(000012)23.02.2011 13:01:05 - anonymous (127.0.0.1)> 550 CWD failed. "/subOne/subTwo/subThree/subOne": directory not found.
(000012)23.02.2011 13:03:06 - anonymous (127.0.0.1)> 421 Connection timed out.
(000012)23.02.2011 13:03:06 - anonymous (127.0.0.1)> disconnected.

I don’t understand at all, why the Tester is trying to get into extended passive mode and why it’s added subOne after it can’t retrieve subFour.

I just installed the FileZilla Server and set up the anonymous user and shared drives. I checked via browser and FileZilla-Client that the FTP-Dir is reachable (same logins of course) and that’s it.
Everything is installed and running on the same machine!

Don’t know any further…

Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:29:01+00:00Added an answer on May 20, 2026 at 5:29 am

    This way to connect to the FTP is quite limited and obscurely documented. I can give you an answer for the EPSV first. The connection is established by internal implementation which in my JDK happens to be sun.net.www.protocol.ftp.FtpURLConnection.

    When connecting to the server first EPSV and PASV will be tried (default is the passive mode) then it will fall back to the active mode – PORT – if the passive mode cannot be established. You can see the implementation details here.

    The essential comment explaining one of your questions is:

     /**
      * Here is the idea:
      *
      * - First we want to try the new (and IPv6 compatible) EPSV command
      *   But since we want to be nice with NAT software, we'll issue the
      *   EPSV ALL cmd first.
      *   EPSV is documented in RFC2428
      * - If EPSV fails, then we fall back to the older, yet OK PASV command
      * - If PASV fails as well, then we throw an exception and the calling method
      *   will have to try the EPRT or PORT command
      */
    

    As for your second question… the unsuccessful retrieval of subFour… Well, at first quick look it seems to behave that way because it is buggy. But I cannot really install the proper environment to verify that now. Further you have the exception. I guess that the problem is initiated on line 455 when it tries to navigate to the full path again. The full source of the FTP connection is here.

    373       public InputStream getInputStream() throws IOException {
      ...
      390           try {
      391               decodePath(url.getPath());
      392               if (filename == null || type == DIR) {
      ...
      399               } else {
      400                   if (type == ASCII)
      401                       ftp.ascii();
      402                   else
      403                       ftp.binary();
      404                   cd(pathname);
      405                   is = new FtpInputStream(ftp, ftp.get(filename));
      406               }
      407   
      408
      ...
      453           } catch (FileNotFoundException e) {
      454               try {
      455                   cd(fullpath);
      456                   /* if that worked, then make a directory listing
      457                      and build an html stream with all the files in
      458                      the directory */
      459                   ftp.ascii();
      460   
      461                   is = new FtpInputStream(ftp, ftp.list());
      462                   msgh.add("content-type", "text/plain");
      463               } catch (IOException ex) {
      464                   throw new FileNotFoundException(fullpath);
      465               }
      466           }
      ...
      469       }
    

    I would advise you to use the Apache Commons Net library for FTP operations. It is much more advanced and straightforward to use.

    Cheers and happy debugging if you feel like!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code demonstrates a weird problem I have in a Turbo C++ Explorer
I have a weird problem using the Java Box class. I am using JDK
i have a weird problem. i would like to delete an assembly(plugin.dll on harddisk)
I have a weird problem with images in visual web developer, I cant change
We have a weird intermittent problem with saving from Word 2007 to our SharePoint
I have a very weird problem: sometimes when I call nHibernate update to an
I have a weird date rounding problem that hopefully someone can solve. My client
This is a weird problem I have started having recently. My team is developing
This is a really weird problem that I have been having. When I download
This is kind of a weird problem, but I have to create a search

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.