Hi,

A project I've begun to maintain has been having problems with staging files using VFS. I have extracted the relevant code bits into a simple app. The app takes an argument of the type "ftp://<host>:<port>/<file>" and expects an anonymous Ftp server to be running at the given address.

When the project uses its original version of VFS - commons-vfs-1.0-SNAPSHOT.jar the
problem is:
"Could not determine if file "ftp://host:port/output"; is writable" - the exception is thrown from
FileObject.getContent().getOuputStream(false) ("Do 3" line in the app).
I get the same error even if I try FileObject.createFile().
This happens if the actual file does not exist, however, if an empty file is created these two methods complete successfully.

I found a similar post in the archives from 31 July'06, but no one responded to it.


When I switch to more recent 'commons-vfs-1.1-SNAPSHOT.jar' or 'commons-vfs-1.0.jar' the problem is: "java.lang.StackOverflowError" - the exception is thrown from FileSystemManager.resolveFile(file) ("Do 1" line in the app). I found a post suggesting that could be a bug with JDK fixed in the latest versions, but I get the same problem when I try with
JDK 1.5.0_10-b03 and 1.6.0-b105.

thnx
Vesso

Java App
********************************

/**
* Main.java
*
* Created on 28 February 2007, 17:40
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package vfstest;

import java.io.OutputStream;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.cache.NullFilesCache;
import org.apache.commons.vfs.impl.DefaultFileSystemManager;
import org.apache.commons.vfs.provider.ftp.FtpFileProvider;

/**
*
* @author vesso
*/
public class Main {
/** Creates a new instance of Main */
   public Main() {
   }
/**
    * @param args the command line arguments
    */
   public static void main(String[] args) {
       System.out.println( "ENTER MAIN" );
try {
           DefaultFileSystemManager xInstance = new DefaultFileSystemManager();
           xInstance.setFilesCache(new NullFilesCache());
           xInstance.addProvider("ftp", new FtpFileProvider());
           xInstance.init();

           System.out.println( "Do 1" );
           FileObject xFileObject = xInstance.resolveFile( args[ 0 ] );
System.out.println( "Do 2" );
           System.out.println( xFileObject.exists() );
System.out.println( "Do 3" );
           //xFileObject.createFile();
           OutputStream xOs = xFileObject.getContent().getOutputStream( false );
System.out.println( "Do 4" );
           System.out.println( xFileObject.exists() );
} catch ( Throwable exc ) {
           System.out.println( "CAUGHT EXCEPTION: " + exc.toString() );
           exc.printStackTrace();
       } finally {
           System.out.println( "EXIT MAIN" );
       }
   }
}

********************************

FileWrite Error
********************************

ENTER MAIN
Do 1
Do 2
false
Do 3
CAUGHT EXCEPTION: org.apache.commons.vfs.FileSystemException: Could not determine if file 
"ftp://<host>:<port>/output.txt" is writeable.
org.apache.commons.vfs.FileSystemException: Could not determine if file 
"ftp://<host>:<port>/output.txt" is writeable.
       at 
org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:475)
       at 
org.apache.commons.vfs.provider.AbstractFileObject.getOutputStream(AbstractFileObject.java:1127)
       at 
org.apache.commons.vfs.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:367)
       at vfstest.Main.main(Main.java:48)
Caused by: org.apache.commons.vfs.FileSystemException: Could not determine if file 
"ftp://<host>:<port>/" is writeable.
       at 
org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:475)
       at 
org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:468)
       ... 3 more
Caused by: org.apache.commons.vfs.FileSystemException: Could not determine the type of file 
"ftp://<host>:<port>/".
       at 
org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject.java:1235)
       at 
org.apache.commons.vfs.provider.AbstractFileObject.isWriteable(AbstractFileObject.java:458)
       ... 4 more
Caused by: java.lang.NullPointerException
       at 
org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
       at 
org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:262)
       at 
org.apache.commons.vfs.provider.AbstractFileObject.getParent(AbstractFileObject.java:503)
       at 
org.apache.commons.vfs.provider.ftp.FtpFileObject.getInfo(FtpFileObject.java:174)
       at 
org.apache.commons.vfs.provider.ftp.FtpFileObject.doAttach(FtpFileObject.java:166)
       at 
org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject.java:1221)
       ... 5 more
EXIT MAIN

********************************

StackOverflowError
********************************

ENTER MAIN
Do 1
CAUGHT EXCEPTION: java.lang.StackOverflowError
java.lang.StackOverflowError
       at java.lang.Class.privateGetDeclaredMethods(Class.java:2382)
       at java.lang.Class.getMethod0(Class.java:2642)
       at java.lang.Class.getMethod(Class.java:1579)
       at 
org.apache.commons.logging.LogFactory.getContextClassLoader(LogFactory.java:438)
       at org.apache.commons.logging.LogFactory$1.run(LogFactory.java:222)
       at java.security.AccessController.doPrivileged(Native Method)
       at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:218)
       at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
       at 
org.apache.commons.vfs.provider.ftp.FtpFileObject.<init>(FtpFileObject.java:53)
       at 
org.apache.commons.vfs.provider.ftp.FtpFileSystem.createFile(FtpFileSystem.java:156)
       at 
org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:296)
       at 
org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
       at 
org.apache.commons.vfs.provider.AbstractFileSystem.getRoot(AbstractFileSystem.java:242)
       at 
org.apache.commons.vfs.provider.AbstractFileObject.getParent(AbstractFileObject.java:510)
       at 
org.apache.commons.vfs.provider.ftp.FtpFileObject.getInfo(FtpFileObject.java:177)
       at 
org.apache.commons.vfs.provider.ftp.FtpFileObject.refresh(FtpFileObject.java:208)
       at 
org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:319)
       at 
org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)

             . . . .
             . . . .
********************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to