2011-11-03 122 views
2

VFS方法無法處理這個在jboss-beans.xml中配置的URI ${jboss.server.temp.dir}/local/outgoing,它被JBoss解析爲"C:\\Download\\jboss-eap-5.1.1\\server\\default\\tmp/local/outgoing"。當我嘗試解析URI並獲取文件時,它會引發異常。任何想法可能是什麼問題?Apache Commons VFS - 無法解析文件

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

我認爲它需要的文件:計劃,因爲錯誤說,它asumed是相對的。

+1

計劃沒有幫助。但問題是FileSystemManager的一個實例。應該爲每個操作創建新的。 – user219882

3

對於這個問題面臨的其他人:我被用

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

更換

FileSystemManager fsManager = VFS.getManager(); 

這讓我使用文件系統管理器多次沒有得到錯誤擺脫這種錯誤的在問題中再次描述。當你完成它時,不要忘了關閉你fsManager

fsManager.close(); 
+0

如果您檢查'VFS.getManager()'後面的代碼,您會看到它創建了一個「StandardFileSystemManager」的靜態實例併爲您啓動或返回當前實例。 – bachr