2013-11-04 73 views
1

我試圖使用在glassfish 4上部署的應用程序使用truevfs庫。如果在獨立的java-se應用程序中使用下面的代碼,但它無法查找文件系統提供者從玻璃魚內部使用時。如何在glassfish 4上使用truevfs META-INF/services 4

這是否起作用?我有什麼選擇?

代碼:

Path uriPath = new TPath(new URI("http://localhost:8080/mytar.tar")); 

try (FileSystem zipfs = FileSystems.newFileSystem(uriPath, null)) { 
    Path pathInZipfile = zipfs.getPath("/"); // <-- error thrown here 
    ... 
} 

的POM:

<dependency> 
    <groupId>net.java.truevfs</groupId> 
    <artifactId>truevfs-profile-default</artifactId> 
    <version>0.10.4</version> 
    <type>pom</type> 
</dependency> 

和錯誤:

Caused by: java.nio.file.ProviderNotFoundException: Provider not found 
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:403) 

回答

0

我把問題truevfs mailing-list和庫的作者回答說:

not sure if it has anything to do with that, but using FileSystems.newFileSystem(Path) is not required. Just pass the TPath object to any of the Files.* methods.

他說得對,使用Files.*方法直接在TPath對象上運行良好。