2013-11-04 54 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对象上运行良好。