Apache Commons VFS - cannot resolveFile

user219882 picture user219882 · Nov 3, 2011 · Viewed 15.5k times · Source

The VFS method cannot process this URI ${jboss.server.temp.dir}/local/outgoing configured in jboss-beans.xml which is resolved to "C:\\Download\\jboss-eap-5.1.1\\server\\default\\tmp/local/outgoing" by JBoss. When I try to resolve the URI and get the file, it throws an exception. Any ideas what could be the problem?

Exception

17:35:25,024 ERROR [VfsSynchronizerConfImpl] File FromOutgoing cannot be resolved, FileSystemException:
org.apache.commons.vfs2.FileSystemException: Could not find file with URI "C:\Download\jboss-eap-5.1.1\server\default\tmp/local/outgoing" because it is a relative path, and no base URI was provided.
    at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:719)
    at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:649)
    at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:605)

DefaultFileSystemManager.class methods

public FileObject resolveFile(final String uri) throws FileSystemException
  -- this method calls the method below

public FileObject resolveFile(final FileObject baseFile, final String uri,
        final FileSystemOptions fileSystemOptions)
        throws FileSystemException
  -- this method cannot process the string and throws
     throw new FileSystemException("vfs.impl/find-rel-file.error", uri);

Answer

Manish Bansal picture Manish Bansal · Jun 13, 2020

Quite old question but popular. This exception is quite generic. For my case, this exception was thrown while uploading files to remote ftp server. And the root cause was missing sftp library in classpath. Just before this exception, vfs tries to resolve the file using one of the provider corresponding to the scheme mentioned in URI.

For my case, scheme was sftp and and it tried to find jsch library on classpath. Since, it was not present on my classpath, this exception was thrown.Therefore, one must keep the provider jar on classpath.