【问题标题】:XMLBeans jar can't be signed when imported from custom class从自定义类导入 XMLBeans jar 时无法签名
【发布时间】:2015-01-12 13:42:03
【问题描述】:

在 NetBeans 中,我创建了一个 Exporter 类,它使用 APACHE POI 将一些数据导出到 EXCEL 文件,该文件使用 XMLBeans。

我通过下载 zip 二进制文件并手动添加 jar 来添加 APACHE POI 3.10.1 库。

当我在同一个项目中使用这个类时,一切运行正常。

然后我将这个类添加到另一个项目中,通过右键单击库 -> 添加项目。

但是当我尝试运行它时,我在编译时遇到了以下错误。

Signing JAR: C:\Users\c\p\dist\lib\xmlbeans-2.6.0.jar to C:\Users\c\p\dist\lib\xmlbeans-2.6.0.jar as nb-jfx
jarsigner: unable to sign jar: java.util.zip.ZipException: duplicate entry:    org/apache/xmlbeans/xml/stream/Location.class
Enter Passphrase for keystore: Enter key password for nb-jfx: 
C:\Users\c\p\nbproject\jfx-impl.xml:1465: The    following error occurred while executing this line:
C:\Users\c\p\nbproject\jfx-impl.xml:2968: The following error occurred while executing this line:
C:\Users\c\p\nbproject\jfx-impl.xml:1940: jarsigner   returned: 1

我不知道这可能是关于什么的,但这让我发疯了。

【问题讨论】:

  • 我现在几乎不记得这个问题了,那是很久以前的事了,但我想我最终使用的是旧版本的 APACHE POI。我希望这会有所帮助。
  • 在最新版本的 POI 中仍然出现

标签: java apache-poi xmlbeans jar-signing


【解决方案1】:

在 XMLBEANS Jira 中打开了一个定义此问题的错误。 https://issues.apache.org/jira/browse/XMLBEANS-499 并且其中一个 cmets 报告了修复。我还没有尝试过,但正在这样做。看看吧。

更新:已解决。事后看来,如果正确创建了 .jar,则该解决方案是显而易见的,但非常不必要。解压缩(我只是将 .jar 扩展名更改为 .zip 并继续)将删除重复的 .class 文件(在本例中为 8 个)的 .jar,然后使用 jar 工具重新创建 .jar 文件。命令是:“jar cf(路径)\xmlbeans-2.6.0.jar -C(解压文件夹路径)。”不要忘记命令末尾的句点。然后我将新的 xmlbeans-2.6.0.jar 复制到我的 lib 目录中,现在一切正常。希望这对其他人有帮助! :-)

【讨论】:

    【解决方案2】:

    如果你使用的是 maven,你可以尝试解压 xmlbeans 依赖。

    <executions>
    <execution>
        <id>unpack-dependencies</id>
        <phase>package</phase>
        <goals>
            <goal>unpack</goal>
        </goals>
        <configuration>
            <artifactItems>
                <artifactItem>
                    <groupId>org.apache.xmlbeans</groupId>
                    <artifactId>xmlbeans</artifactId>
                    <version>2.6.0</version>
                    <type>jar</type>
                    <overWrite>true</overWrite>
                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
                    <excludes>**/*test.class</excludes>
                </artifactItem>
            </artifactItems>
        </configuration>
    </execution>
    </executions>
    

    【讨论】:

      猜你喜欢
      • 2019-01-20
      • 2019-05-31
      • 1970-01-01
      • 2013-08-04
      • 2021-11-25
      • 1970-01-01
      • 2013-07-30
      • 1970-01-01
      • 2021-10-16
      相关资源
      最近更新 更多