【问题标题】:how to use truevfs META-INF/services on glassfish 4如何在 glassfish 4 上使用 truevfs META-INF/服务
【发布时间】:2013-11-04 20:29:01
【问题描述】:

我正在尝试使用 glassfish 4 上部署的应用程序中的 truevfs 库。如果在独立的 java-se 应用程序中使用下面的代码效果很好,但在 glassfish 内部使用时无法查找文件系统提供程序。

这应该有效吗?我有什么选择?

代码:

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)

【问题讨论】:

    标签: jakarta-ee glassfish-4 serviceloader truevfs


    【解决方案1】:

    我把问题发给truevfs mailing-list,图书馆的作者回答:

    不确定是否与此有关,但使用 FileSystems.newFileSystem(Path) 不是必需的。只需通过 TPath 反对任何 Files.* 方法。

    他是对的,直接在 TPath 对象上使用 Files.* 方法效果很好。

    【讨论】:

      猜你喜欢
      • 2016-10-02
      • 2012-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多