commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ibrahim Hasbini <>
Subject [vfs] directory creation through VFS + FTP intermittently fails with FileSystemException
Date Thu, 12 Jan 2012 10:06:08 GMT

I've been facing an issue where simultaneous threads may be creating
the same directory (using VFS + FTP storage) and failing with the
exception shown below.
I thought I'd post about this issue to see if anyone faced a similar
issue and could help.

When I first encountered the exception I thought I'd catch it and
check to see if the directory being created already existed (i.e.
possibly another thread created it), and if it did then ignore the
However even with that check, the exception is occurring intermittently.

I have also looked at the code of
org.apache.commons.vfs.provider.ftp.FtpFileObject.doCreateFolder() and
it seems that the result code returned by the FTP server is hidden,
because the call to FtpClient.makeDirectory() just returns a boolean
to indicate success or failure.

Here's my code that calls VFS's createFolder():

   private void createFolderInternal(FileObject storageFileObject)
throws Exception {
       if (storageFileObject.getParent() != null) {
       try {
       } catch (FileSystemException fsex) {
           if (storageFileObject.getParent() != null) {
           if (!storageFileObject.exists()) {
               throw fsex;

below is the exception:

org.apache.commons.vfs.FileSystemException: Could not create folder
    at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(
    at m.a.c.s.vfs.VFSStorageFile.createFolderInternal(
    at m.a.c.s.vfs.VFSStorageFile.createFolder(
    at m.a.c.b.DefaultBuilder.storeOutputInternal(
    at m.a.c.b.DefaultBuilder.storeOutput(
    at sun.reflect.GeneratedMethodAccessor340.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at m.a.c.a.AsyncAgent$
    at java.util.concurrent.Executors$
    at java.util.concurrent.FutureTask$Sync.innerRun(
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
    at java.util.concurrent.ThreadPoolExecutor$
Caused by: org.apache.commons.vfs.FileSystemException: Could not
create folder "ftp://ftpserver/builds/storages/storage1/logs/1788251-120106-1831-19812".
    at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(
    at org.apache.commons.vfs.provider.DelegateFileObject.doCreateFolder(
    at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(
    ... 15 more
Caused by: org.apache.commons.vfs.FileSystemException: Could not
create FTP directory
    at org.apache.commons.vfs.provider.ftp.FtpFileObject.doCreateFolder(
    at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(
    ... 17 more

Thank you,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message