Apache Commons VFS - cannot resolveFile

旧街凉风 提交于 2019-12-10 21:26:57

问题


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);

回答1:


I think it needs the file: scheme because the error says it's asumed to be relative.




回答2:


For other people facing with this issue: I got rid of this error by replacing

FileSystemManager fsManager = VFS.getManager();

with

StandardFileSystemManager fsManager = new StandardFileSystemManager();
fsManager.init();

This allowed me to use the file system manager multiple times without getting the error anymore described in the question. Don't forget to close you fsManager when you're done with it:

fsManager.close();


来源:https://stackoverflow.com/questions/7998574/apache-commons-vfs-cannot-resolvefile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!