【问题标题】:java.nio.file.FileSystemNotFoundException: Provider 'wsjar' not installedjava.nio.file.FileSystemNotFoundException:未安装提供程序“wsjar”
【发布时间】:2014-03-05 00:37:10
【问题描述】:

由于未正确找到文件路径,我收到此异常报告。

Caused by: java.nio.file.FileSystemNotFoundException: Provider "wsjar" not installed
    at java.nio.file.Paths.get(Paths.java:158)

我正在运行 Websphere v8.5.5.0。

我这样称呼路径:

Class<?> clazz = ...
URI uri = clazz.getResource("/project.properties").toURI();
Path propertyFilePath = Paths.get(uri); //error here.

有人可以解释一下 wsjar 文件名的含义吗?我能做些什么来解决这个错误?

附:一旦我使用 System.out.println 语句运行它,我将在此处获得实际的 uri.toString。

更新:实际的URI字符串如下:

wsjar:file:/C:/Program%20Files%20(x86)/IBM/WebSphere/AppServer_1/profiles/AppSrv01/installedApps/AUSSYDCVTLJ007Node02Cell/myapp.ear/lib/core.jar!/project.properties

【问题讨论】:

    标签: java websphere


    【解决方案1】:

    wsjar 是 jar 文件中条目的特定于 websphere 的 URL 协议。

    可以从您的代码中完成的一种解决方案是重建 URL,如下所示:

     if (uri.getProtocol().startsWith("wsjar")) 
         URL updatedURL = new URL("jar", uri.getHost(), uri.getPort(), uri.getPath());
    

    此处讨论了类似的问题。 https://issues.apache.org/jira/browse/XW-669

    【讨论】:

    • URI 没有.getProtocol() 方法。同样,当我在新 URL 中输出这三个 uri 函数的状态时,我得到uri.getHost() == null, uri.getPort() == -1 and uri.getPath() == null
    • 它应该是 URL。 URL url = clazz.getResource("/project.properties");从这里你应该能够使用协议和其他方法。
    猜你喜欢
    • 2021-05-14
    • 2013-10-19
    • 1970-01-01
    • 2022-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多