首页 > 解决方案 > 在引导 Corda 网络时出现“错误:无效或损坏的 jarfile corda.jar”

问题描述

在尝试引导 Corda 网络时出现错误。

错误:无效或损坏的 jarfile corda.jar

请在下面找到更多详细信息。

root@domestic-lc:/home/POC_DomesticLC# java -jar corda-tools-network-bootstrapper-4.0.jar --dir build/nodes
Bootstrapping local test network in /home/POC_DomesticLC/build/nodes
Using corda.jar in root directory
Generating node directory for PartyB
Generating node directory for BankB
Generating node directory for Notary
Generating node directory for BankA
Generating node directory for PartyA
Nodes found in the following sub-directories: [PartyA, PartyB, BankB, BankA, Notary]
Found the following CorDapps: []
Not copying CorDapp JARs as --copy-cordapps is set to FirstRunOnly, and it looks like this network has already been bootstrapped.
Waiting for all nodes to generate their node-info files...
#### Error while generating node info file /home/POC_DomesticLC/build/nodes/PartyA/logs ####
Error: Invalid or corrupt jarfile corda.jar
#### Error while generating node info file /home/POC_DomesticLC/build/nodes/PartyB/logs ####
Error: Invalid or corrupt jarfile corda.jar
#### Error while generating node info file /home/POC_DomesticLC/build/nodes/BankA/logs ####
Error: Invalid or corrupt jarfile corda.jar
#### Error while generating node info file /home/POC_DomesticLC/build/nodes/BankB/logs ####
Error: Invalid or corrupt jarfile corda.jar
#### Error while generating node info file /home/POC_DomesticLC/build/nodes/Notary/logs ####
Error: Invalid or corrupt jarfile corda.jar
Error while generating node info file. Please check the logs in /home/POC_DomesticLC/build/nodes/PartyA/logs.

标签: blockchaincorda

解决方案


我遇到了类似的问题(不是那个特定的 JAR 文件,但我在示例中使用了该文件的名称)。以下是我如何找出问题所在。

这些故障排除步骤可能会帮助发现此问题的其他人(但不是 OP,因为日期显示它不可能是这个问题)。

我首先尝试通过检查 JAR 文件的内容来验证它:

$ jar -tf corda.jar

这表明我确实是无效的。就我而言,我看到:

java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:225)
    at java.util.zip.ZipFile.<init>(ZipFile.java:155)
    at java.util.zip.ZipFile.<init>(ZipFile.java:126)
    at sun.tools.jar.Main.list(Main.java:1115)
    at sun.tools.jar.Main.run(Main.java:293)
    at sun.tools.jar.Main.main(Main.java:1288)

然后我查看了文件的大小:

$ ls -alh corda.jar

在我的例子中,它是 133 字节,对于 JAR 文件来说似乎有点小,所以我cat编辑它并看到了这个:

$ cat corda.jar

501 HTTPS Required. 
Use https://repo1.maven.org/maven2/
More information at https://links.sonatype.com/central/501-https-required

事实证明,我的脚本(实际上是 Dockerfile)正在使用curl -o不再支持的 URL 下载文件。正如https://links.sonatype.com/central/501-https-required所说:

自 2020 年 1 月 15 日起,中央存储库不再支持通过纯 HTTP 进行的不安全通信,并要求对存储库的所有请求都通过 HTTPS 进行加密。

如果您收到此错误,则需要将所有对 Maven Central 的 URL 引用替换为其规范的 HTTPS 对应项:

http://repo1.maven.org/maven2/替换为https://repo1.maven.org/maven2/

http://repo.maven.apache.org/maven2/替换为https://repo.maven.apache.org/maven2/

如果由于任何原因您的环境不支持 HTTPS,您可以选择使用我们在http://insecure.repo1.maven.org/maven2/上的专用不安全端点

有关迁移到 HTTPS 的更多背景信息,请参阅https://blog.sonatype.com/central-repository-moving-to-https

这是相当具体的,但可能会对某人有所帮助。


推荐阅读