gpt4 book ai didi

java - 安装java链码抛出无效内存地址错误

转载 作者:太空宇宙 更新时间:2023-11-04 09:56:14 25 4
gpt4 key购买 nike

我使用 1.4.0-rc2 作为 docker 镜像和 java 代码。

当尝试使用以下命令将 java chaincode 从 cli 安装到对等点时:

peer chaincode install -p github.com/hyperledger/chaincode/java/ -l java -n java_chaincode -v 0

抛出以下错误:

2019-01-09 14:36:11.799 UTC [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2019-01-09 14:36:11.819 UTC [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2019-01-09 14:36:11.824 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2019-01-09 14:36:11.824 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xea273b]

goroutine 1 [running]:
github.com/hyperledger/fabric/core/container/util.WriteFolderToTarPackage.func1(0x7fffb7459543, 0x31, 0x0, 0x0, 0x1874100, 0xc0002c4a50, 0x60, 0x1691f40)
/opt/gopath/src/github.com/hyperledger/fabric/core/container/util/writer.go:64 +0xcb
path/filepath.Walk(0x7fffb7459543, 0x31, 0xc0003b8c60, 0x2, 0x3)
/opt/go/src/path/filepath/path.go:402 +0x6a
github.com/hyperledger/fabric/core/container/util.WriteFolderToTarPackage(0xc00011dc00, 0x7fffb7459543, 0x31, 0xc000435858, 0x3, 0x3, 0x0, 0xc00012dc80, 0xc00011dc00, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/core/container/util/writer.go:136 +0x241
github.com/hyperledger/fabric/core/container/util.WriteJavaProjectToPackage(0xc00011dc00, 0x7fffb7459543, 0x31, 0xc000435940, 0x1)
/opt/gopath/src/github.com/hyperledger/fabric/core/container/util/writer.go:152 +0x158
github.com/hyperledger/fabric/core/chaincode/platforms/java.(*Platform).GetDeploymentPayload(0x2429b40, 0x7fffb7459543, 0x32, 0x4, 0xc000167188, 0x1716e01, 0x4, 0xc0004359c0)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/platforms/java/platform.go:123 +0x1e0
github.com/hyperledger/fabric/core/chaincode/platforms.(*Registry).GetDeploymentPayload(0xc00000c540, 0x1716e08, 0x4, 0x7fffb7459543, 0x32, 0x4, 0x7fffb7459543, 0x32, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/platforms/platforms.go:103 +0x8f
github.com/hyperledger/fabric/core/container.GetChaincodePackageBytes(0xc00000c540, 0xc00024a5c0, 0x0, 0x16740c0, 0xc0000b2cd0, 0xc000040704, 0x4)
/opt/gopath/src/github.com/hyperledger/fabric/core/container/controller.go:191 +0xc7
github.com/hyperledger/fabric/peer/chaincode.getChaincodeDeploymentSpec(0xc00024a5c0, 0xc00024a501, 0x0, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/common.go:58 +0x11c
github.com/hyperledger/fabric/peer/chaincode.genChaincodeDeploymentSpec(0xc0000c4c80, 0x7fffb7459581, 0x1b, 0x7fffb74595a0, 0x1, 0x0, 0x8020106, 0x2)
/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/install.go:109 +0xac
github.com/hyperledger/fabric/peer/chaincode.chaincodeInstall(0xc0000c4c80, 0x0, 0x0, 0xc00003a4d0, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/install.go:177 +0x156
github.com/hyperledger/fabric/peer/chaincode.installCmd.func1(0xc0000c4c80, 0xc000150480, 0x0, 0x8, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/install.go:44 +0x54
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).execute(0xc0000c4c80, 0xc000150300, 0x8, 0x8, 0xc0000c4c80, 0xc000150300)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:762 +0x473
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x2320300, 0x8, 0x0, 0x231f4c0)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:852 +0x2fd
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).Execute(0x2320300, 0xc00044ff40, 0x1)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:800 +0x2b
main.main()
/opt/gopath/src/github.com/hyperledger/fabric/peer/main.go:53 +0x2f7

该文件夹内有一个按照教程创建的 jar,即 on github .

编辑1:

上面的错误是因为路径不正确,我使用的是相对于 gopath 的路径,因为我之前必须对 go 链码执行此操作,但使用完整路径可以进行安装。

对于实例化:

peer chaincode instantiate -n chaincode -v 0 -C channel -c '{"Args":["init"]}' -l java

出现以下错误:

Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 127 "/bin/sh: 1: ./build.sh: not found
"

这是同行的日志:

2019-01-10 07:43:44.504 UTC [chaincode.platform.java] GenerateDockerBuild -> ERRO 3e9 Can't build java chaincode Error returned from build: 127 "/bin/sh: 1: ./build.sh: not found
"
2019-01-10 07:43:44.505 UTC [chaincode.platform] func1 -> ERRO 3ea Failed to generate platform-specific docker build: Error returned from build: 127 "/bin/sh: 1: ./build.sh: not found
"
2019-01-10 07:43:44.505 UTC [dockercontroller] deployImage -> ERRO 3eb Error building image: Failed to generate platform-specific docker build: Error returned from build: 127 "/bin/sh: 1:./build.sh: not found
"
2019-01-10 07:43:44.505 UTC [dockercontroller] deployImage -> ERRO 3ec Build Output:
********************

********************
2019-01-10 07:43:44.507 UTC [endorser] callChaincode -> INFO 3ed [channel][6ba7c224] Exit chaincode: name:"lscc" (1563ms)
2019-01-10 07:43:44.507 UTC [endorser] SimulateProposal -> ERRO 3ee [channel][6ba7c224] failed to invoke chaincode name:"lscc" , error: Failed to generate platform-specific docker build: Error returned from build: 127 "/bin/sh: 1: ./build.sh: not found
"
error starting container
error starting container

我很乐意提供更多信息和代码。

最佳答案

直接从 jar 安装链代码并不是那么简单,您需要更改脚本或从 jar 文件创建自定义镜像,我花了几个小时才弄清楚这一点。对于,

peer chaincode install and peer chaincode instantiate

源代码是“必需的”,因为对等方执行“docker pull”来下载 java 特定镜像,以便在内部构建它并启动链码容器。您可以执行 docker exec 来检查 chaincode.jar 是否在 chaincode 容器内创建。

现在遇到您的错误运行时错误:无效的内存地址或零指针取消引用,您可以检查路径是否正确,并共享对等日志,我很乐意提供帮助。

关于java - 安装java链码抛出无效内存地址错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54112720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com