【问题标题】:Install java chaincode throws an invalid memory address error安装 java 链码抛出无效内存地址错误
【发布时间】:2019-01-09 14:47:29
【问题描述】:

我将 1.4.0-rc2 用于 docker 图像和 java 代码。

当尝试使用以下命令将 java 链代码从 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

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

【问题讨论】:

    标签: java hyperledger-fabric hyperledger


    【解决方案1】:

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

    对等链码安装和对等链码实例化

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

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

    【讨论】:

    • 当您说源代码时,您是在谈论整个 gradle 项目还是只是 src 文件夹?非常感谢,将添加日志。
    • 天哪,非常感谢,我认为我必须使用相对于 gopath 的路径,因为我必须使用 go 链码来做到这一点,但它对我使用整个路径很有用.所以你是对的,是关于路径。但是现在当我尝试 instatiate 给我以下错误。 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 "
    • 源代码是指没有任何构建或 jar 文件的 gradle 项目。这是一个例子github.com/hyperledger/fabric-samples/tree/release-1.4/…
    • 通过运行检查对等日志 - docker logs ,更新我
    • 感谢Harchit,我已经添加了peer的日志
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-15
    相关资源
    最近更新 更多