You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by richard head <du...@hotmail.com> on 2008/05/29 00:26:08 UTC

VFS FTP AbstractFileObject.isWriteable() Causes NullPointerException

Two problems:



1. I receive a NullPointerException from
AbstractFileObject.isWriteable() when I attempt to copy
VFSFTPTest.class from a local directory to one on a FTP server:



org.apache.commons.vfs.FileSystemException: Could not determine if file
"ftp://mss:XXXX@192.168.9.161/home/logs/preview/VFSFTPTest.class" is
writeable.


        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:515)


        at org.apache.commons.vfs.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:891)


        at org.apache.commons.vfs.impl.DecoratedFileObject.copyFrom(DecoratedFileObject.java:60)


        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.copyFrom(OnCallRefreshFileObject.java:51)


        at org.apache.commons.vfs.provider.AbstractFileObject.moveTo(AbstractFileObject.java:995)


        at org.apache.commons.vfs.impl.DecoratedFileObject.moveTo(DecoratedFileObject.java:155)


        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.moveTo(OnCallRefreshFileObject.java:141)


        at VFSFTPTest.main(VFSFTPTest.java:36)


Caused by: org.apache.commons.vfs.FileSystemException: Could not
determine if file "ftp://mss:XXXX@192.168.9.161/home/logs/preview" is
writeable.


        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:515)


        at org.apache.commons.vfs.impl.DecoratedFileObject.isWriteable(DecoratedFileObject.java:150)


        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.isWriteable(OnCallRefreshFileObject.java:135)


        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:508)


        ... 7 more


Caused by: org.apache.commons.vfs.FileSystemException: Could not
determine if file "ftp://mss:XXXX@192.168.9.161/home/logs" is writeable.


        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:515)


        at org.apache.commons.vfs.impl.DecoratedFileObject.isWriteable(DecoratedFileObject.java:150)


        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.isWriteable(OnCallRefreshFileObject.java:135)


        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:508)


        ... 10 more


Caused by: org.apache.commons.vfs.FileSystemException: Could not
determine if file "ftp://mss:XXXX@192.168.9.161/home" is writeable.


        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:515)


        at org.apache.commons.vfs.impl.DecoratedFileObject.isWriteable(DecoratedFileObject.java:150)


        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.isWriteable(OnCallRefreshFileObject.java:135)


        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:508)


        ... 13 more


Caused by: java.lang.NullPointerException


        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:272)


        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)


        at org.apache.commons.vfs.provider.AbstractFileObject.getParent(AbstractFileObject.java:543)


        at org.apache.commons.vfs.provider.ftp.FtpFileObject.getInfo(FtpFileObject.java:182)


        at org.apache.commons.vfs.provider.ftp.FtpFileObject.refresh(FtpFileObject.java:212)


        at org.apache.commons.vfs.impl.DecoratedFileObject.refresh(DecoratedFileObject.java:170)


        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.isWriteable(OnCallRefreshFileObject.java:134)


        at org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:508)



What can be preventing the library from determining if my target directory is writable? The FTP client works fine, there are no
permissions issues. 

Though in the past (http://mail-archives.apache.org/mod_mbox/commons-user/200801.mbox/%3CBLU130-W265D17DC82343B2262536ACE390@phx.gbl%3E) I've had issues with VFS giving me FTP 553 errors when there were clearly no permissions issues. 


Here's the code:



    StandardFileSystemManager manager;   

    manager = new StandardFileSystemManager();

    manager.setCacheStrategy(CacheStrategy.ON_CALL);

    manager.init();



    try {

        FileObject destDir = manager.resolveFile(argv[1]);

        FileObject watch = manager.resolveFile(argv[0]);

        

        for(;;) {



           System.err.println("Monitering " +  watch + " copying to " + destDir);

           FileObject newFiles[] = watch.findFiles(new FileDepthSelector(1,1));

           if(newFiles==null) {

              System.err.println("Null!");           

           }

           else {

         System.err.println("Length == " + newFiles.length);

         for(int i=0; i<newFiles.length; i++) {

             System.err.println("Found: " + newFiles[i]);           

             // If we're moving to a folder, we must create the file in that folder, then move its contents.

             FileObject destFile = destDir.resolveFile(newFiles[i].getName().getBaseName());

             System.err.println("Moving " + newFiles[i] + " to " + destFile);

             newFiles[i].moveTo(destFile);

         }    

           }

           Thread.currentThread().sleep(60000);

        }

    }

    catch(Exception e) {

        e.printStackTrace();

    }    






2. file.findFiles() will return a 0 length array, or a null array depending on the FTP server I connect to. 

   This should be consistent, one or the other, don't you think?

   


_________________________________________________________________
Give to a good cause with every e-mail. Join the i’m Initiative from Microsoft.
http://im.live.com/Messenger/IM/Join/Default.aspx?souce=EML_WL_ GoodCause

Re: VFS FTP AbstractFileObject.isWriteable() Causes NullPointerException

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi Richard!
>> Could you please try the latest VFS (aka 2.0) nightly build, there a lot 
>> of stuff in this area has been changed.
>>     
>
> Hi! No luck. 
>   
Ok, no worries, at least we have a stacktrace matching the current
source-base. I'll see what I can do to fix this.

Thanks!
Ciao,
Mario


RE: VFS FTP AbstractFileObject.isWriteable() Causes NullPointerException

Posted by richard head <du...@hotmail.com>.
> > 1. I receive a NullPointerException from
> > AbstractFileObject.isWriteable() when I attempt to copy
> > VFSFTPTest.class from a local directory to one on a FTP server:
> >   
> Could you please try the latest VFS (aka 2.0) nightly build, there a lot 
> of stuff in this area has been changed.

Hi! No luck. 

Checked out the source from http://svn.apache.org/repos/asf/commons/proper/vfs/trunk and tried again with commons-vfs-2.0-SNAPSHOT.jar. This time I received: 

org.apache.commons.vfs.FileSystemException: Could not copy "file:///home/watchit/ftp-test/test/dummy-test-file" to 
"ftp://mss:XXXX@192.168.9.161/home/logs/preview/dummy-test-file".
        at org.apache.commons.vfs.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:976)
        at org.apache.commons.vfs.impl.DecoratedFileObject.copyFrom(DecoratedFileObject.java:60)
        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.copyFrom(OnCallRefreshFileObject.java:51)
        at org.apache.commons.vfs.provider.AbstractFileObject.moveTo(AbstractFileObject.java:1038)
        at org.apache.commons.vfs.impl.DecoratedFileObject.moveTo(DecoratedFileObject.java:155)
        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.moveTo(OnCallRefreshFileObject.java:141)
        at VFSFTPTest.main(VFSFTPTest.java:40)
Caused by: org.apache.commons.vfs.FileSystemException: Could not determine the type of file "ftp://mss:XXXX@192.168.9.161/".
        at org.apache.commons.vfs.provider.AbstractFileObject.getType(AbstractFileObject.java:450)
        at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(AbstractFileObject.java:880)
        at org.apache.commons.vfs.impl.DecoratedFileObject.createFolder(DecoratedFileObject.java:70)
        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.createFolder(OnCallRefreshFileObject.java:63)
        at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(AbstractFileObject.java:900)
        at org.apache.commons.vfs.impl.DecoratedFileObject.createFolder(DecoratedFileObject.java:70)
        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.createFolder(OnCallRefreshFileObject.java:63)
        at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(AbstractFileObject.java:900)
        at org.apache.commons.vfs.impl.DecoratedFileObject.createFolder(DecoratedFileObject.java:70)
        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.createFolder(OnCallRefreshFileObject.java:63)
        at org.apache.commons.vfs.provider.AbstractFileObject.createFolder(AbstractFileObject.java:900)
        at org.apache.commons.vfs.impl.DecoratedFileObject.createFolder(DecoratedFileObject.java:70)
        at org.apache.commons.vfs.cache.OnCallRefreshFileObject.createFolder(OnCallRefreshFileObject.java:63)
        at org.apache.commons.vfs.provider.AbstractFileObject.getOutputStream(AbstractFileObject.java:1314)
        at org.apache.commons.vfs.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:411)
        at org.apache.commons.vfs.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:394)
        at org.apache.commons.vfs.FileUtil.copyContent(FileUtil.java:100)
        at org.apache.commons.vfs.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:967)
        ... 6 more
Caused by: java.lang.NullPointerException
        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:272)
        at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
        at org.apache.commons.vfs.provider.AbstractFileObject.getParent(AbstractFileObject.java:552)
        at org.apache.commons.vfs.provider.ftp.FtpFileObject.getInfo(FtpFileObject.java:194)
        at org.apache.commons.vfs.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:321)
        at org.apache.commons.vfs.provider.AbstractFileObject.getType(AbstractFileObject.java:441)
        ... 23 more




> > 2. file.findFiles() will return a 0 length array, or a null array depending on the FTP server I connect to. 
> >
> >    This should be consistent, one or the other, don't you think?
> >   
> Even this is changed in the version mentioned above. Please give it a try.

Same results. 


_________________________________________________________________
E-mail for the greater good. Join the i’m Initiative from Microsoft.
http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_ GreaterGood

Re: VFS FTP AbstractFileObject.isWriteable() Causes NullPointerException

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> 1. I receive a NullPointerException from
> AbstractFileObject.isWriteable() when I attempt to copy
> VFSFTPTest.class from a local directory to one on a FTP server:
>   
Could you please try the latest VFS (aka 2.0) nightly build, there a lot 
of stuff in this area has been changed.
It seems the VFS nightly build system if broken again, you have to build 
a version yourself by gathering the source from svn as described here [1]
and using maven 2 to build with "mvn -DskipTests install" from within 
the checked out VFS directory. But probably you know that :-)

> 2. file.findFiles() will return a 0 length array, or a null array depending on the FTP server I connect to. 
>
>    This should be consistent, one or the other, don't you think?
>   
Even this is changed in the version mentioned above. Please give it a try.

Ciao,
Mario


[1] http://commons.apache.org/vfs/download.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org