【问题标题】:Application fails to find XSD file using One-Jar应用程序无法使用 One-Jar 找到 XSD 文件
【发布时间】:2011-11-06 12:55:33
【问题描述】:

我正在使用 One-Jar 的 maven 插件将我的 java 打包到一个包含所有依赖项的 jar 中。

该项目有一个名为 schema.xsd 的资源。

当我使用 java -jar myJar.one-jar 运行 jar 文件时,出现以下错误:

 org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document
 'jar:file:/../lib/myJar.one-jar.jar!/lib/myJar.jar!/schema.xsd', because 1) could not find 
the document; 2) the document could not be read; 3) the root element of the document is not 
<xsd:schema>.

知道为什么会这样吗?

注意:应用程序有一个 log4j.properties 作为资源并且它可以识别它。

【问题讨论】:

    标签: java maven xsd executable-jar


    【解决方案1】:

    我很确定 jre 中的 Jar url 连接处理实现不能处理超过一层的嵌套(该 url 中有 2 个“!”字符)。不确定 one-jar 如何处理从嵌套 jar 中读取类文件,但您可能需要先将 xsd 提取到临时文件中,然后才能使用它。

    就个人而言,我通常使用具有“jar-with-dependencies”目标的 maven 程序集插件,除非您的一个或多个 jar 中有冲突的文件,否则它工作得很好。

    【讨论】:

    • One-Jar 应该知道如何处理多个 '!'人物。见here
    • @summerbulb - 实际上,根据该链接,onejar 似乎使用了不使用多个“!”的自定义 url 方案字符
    • 看来你是对的。但这只会让问题变得更加奇怪。
    猜你喜欢
    • 1970-01-01
    • 2019-05-04
    • 2016-05-23
    • 1970-01-01
    • 1970-01-01
    • 2020-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多