java Apache Commons VFS - 无法解析文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7998574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 22:37:17  来源:igfitidea点击:

Apache Commons VFS - cannot resolveFile

javajbossapache-commons-vfs

提问by user219882

The VFS method cannot process this URI ${jboss.server.temp.dir}/local/outgoingconfigured in jboss-beans.xmlwhich 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?

VFS 方法无法处理由 JBoss解析的此 URI${jboss.server.temp.dir}/local/outgoing配置。当我尝试解析 URI 并获取文件时,它会引发异常。任何想法可能是什么问题?jboss-beans.xml"C:\\Download\\jboss-eap-5.1.1\\server\\default\\tmp/local/outgoing"

Exception

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

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

采纳答案by Bernd

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

我认为它需要 file: 方案,因为错误表明它被认为是相对的。

回答by Voicu

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 fsManagerwhen you're done with it:

这使我可以多次使用文件系统管理器而不会再出现问题中描述的错误。完成后不要忘记关闭您fsManager

fsManager.close();