我将1.4.0-rc2用于Docker映像和Java代码。
当尝试使用以下命令从cli向对等方安装Java链码时:
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
在该文件夹内是一个根据教程on github创建的jar。
编辑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
我很乐意提供更多信息和代码。
答案 0 :(得分:0)
直接从jar中安装chaincode并不是那么简单,您需要为此更改脚本或从jar文件中创建自定义映像,我花了数小时来弄清楚这一点。对于,
对等链码安装和对等链码实例化
源代码是“必需的”,因为对等方执行“ docker pull”以下载特定于Java的映像,以便内部构建它并启动chaincode容器。您可以执行 docker exec 来检查chaincode.jar是否在chaincode容器内创建。
现在出现您的错误运行时错误:无效的内存地址或nil指针取消引用,您能否检查路径是否正确并共享对等日志,我很乐意提供帮助。