Issue Details (XML | Word | Printable)

Key: VFS-201
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Satish Kumar Kommuri
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Commons VFS

FTP is failing by saying "File doesn't exist" even the file exists and a valid file.

Created: 29/Feb/08 01:35 PM   Updated: 30/Mar/08 08:16 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Linux
Issue Links:
Reference
 


 Description  « Hide
Hi,

We are facing a strange problem with vfs file transfer from one of the FTP locations. Java code throws the FileSystemException by saying "<particular file> does not exist". On the other hand, FTP to that site and wget are working.

Moreover, from the same machine we are able to FTP from the command line and able to download the file using get command.
And also, wget works fine. No idea the same is failing from java.

Please find the code snippent below:

FileSystemOptions fso = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(fso, "no");

FileObject sourceFileObject = fsm.resolveFile(sourceUri, fso);
String sourceFilePath = sourceFileObject.getName().getPath();

FileObject targetFileObject = fsm.resolveFile(targetUri, fso);

FileObject tfo = targetFileObject;
if(tfo.getType() == FileType.FOLDER)
tfo = targetFileObject.resolveFile(sourceFileObject.getName().getBaseName());
LOGGER.info("The URI is a file");
LOGGER.info("Remote Path: [" + sourceFileObject.getName().getPath() + "] Local Path: [" + tfo.getName().getPath() + "]");
copyFile(sourceFileObject, tfo);

copyFrom method:

private void copyFile(FileObject sourceFileObject, FileObject targetFileObject)
{ targetFileObject.copyFrom(sourceFileObject, new AllFileSelector()); copiedFiles.add(sourceFileObject.getName().getPath()); } catch (FileSystemException e)

{ failedFiles.add(sourceFileObject.getName().getPath()); failedFileExceptions.add(e); LOGGER.error("Exception in FileTransferAgent:copyFile "+e); }

}

exception is:

Exception in FileTransferAgent:copyFile org.apache.commons.vfs.FileSystemException: Could not copy "ftp://usename:password@ipaddress/home/blrproj/console.out" because it does not exist.
org.apache.commons.vfs.FileSystemException: Could not copy "ftp://usename:password@ipaddress/home/blrproj/console.out" because it does not exist.
at org.apache.commons.vfs.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:858)
at FileTransferAgent.copyFile(FileTransferAgent.java:153)
at FileTransferAgent.copyFiles(FileTransferAgent.java:131)
at FileTransferAgent.main(FileTransferAgent.java:238)



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Andrew Franklin added a comment - 02/Mar/08 04:34 AM
You're setting an SFTP Property:

SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(fso, "no");

and connecting to an FTP server:

"ftp://usename:password@ipaddress/home/blrproj/console.out"

... if your intention is to connect to an SFTP server, try:

"sftp://usename:password@ipaddress/home/blrproj/console.out".


Oliver Haider added a comment - 03/Mar/08 01:34 PM - edited
Hi,

we were facing the same "<particular file> does not exist" problem last Friday (the 29. of February).

After tracing the Problem for quite a while we figured out the problem was caused by the intercalary day. The Apache-FTP-Code tries to parse the target/source-File Date on the FTP site and can't cope with the 29.02 returning a "null" instead of a Fileobject and thus returning a "file not found".

I think this Problem even occurs if any of the root-directories got a timestamp on that day. Hope we get a fix within the next 4 years

Regards

Oliver


Sebb added a comment - 03/Mar/08 01:39 PM
Looks like this is similar to NET-188

Satish Kumar Kommuri added a comment - 04/Mar/08 12:20 PM
Adding to the problem,

The same code works fine from one machine and doesn't work from another. Even though both are Linux machines. Don't know where it is going wrong. Could you please suggest which and all parameters to be verified and corrected in a machine to make this work.


Alex Marshall added a comment - 30/Mar/08 05:45 PM - edited
Hello,

I'm facing this exact same problem :

FileSystemManager manager = VFS.getManager();
FileSystemOptions options = new FileSystemOptions();

FtpFileSystemConfigBuilder.getInstance().setPassiveMode(options, true);

FileObject file = manager.resolveFile("ftp://myusername:mypassword@myip:21/test.txt", options);

InputStream fileStream = file.getContent().getInputStream();

IOUtils.copy(fileStream, System.out);

file.close();

...and the exception I get is :
Exception in thread "main" org.apache.commons.vfs.FileSystemException: Could not read from "ftp://myusername:mypassword@myip:21/test.txt" because it is a not a file.
at org.apache.commons.vfs.provider.AbstractFileObject.getInputStream(AbstractFileObject.java:1109)
at org.apache.commons.vfs.provider.DefaultFileContent.getInputStream(DefaultFileContent.java:317)
at eu.alenislimited.chequeProcessing.tests.FTPClientTest.test1(FTPClientTest.java:45)
at eu.alenislimited.chequeProcessing.tests.FTPClientTest.main(FTPClientTest.java:21)

...even though I can open up an FTP client, log in, and verify that the file 'test.txt' is in fact in the root of the FTP after log in.


James Carman added a comment - 30/Mar/08 07:20 PM
Are you guys facing this problem with symbolic links? I opened another issue which addresses symbolic links that it says is not a file.

Alex Marshall added a comment - 30/Mar/08 08:16 PM
No, I'm not facing this problem with symlinks.

Actually, after spending the last several hours debugging in Eclipse, I traced the problem down to my server not being correctly configured to enable passive mode. As a result, I'm able to successfully log in, but when org.apache.commons.net.ftp.FTPClient.pasv() is called internally by the FTPClient which is used by the FTP module of commons VFS, it does not properly handle the return code for 500 Invalid command in response to attempting to get the FTP server to change to passive mode. This was after testing for active mode within the Commons NET FTP client. To my mind, this code should fallback to active mode if it can't connect in passive. I was able to remedy my situation by changing the FileSystemOptions I was using and forcefully disabling passive mode,

ie FtpFileSystemConfigBuilder.sePassiveMode(opt, false)