fabric 1.4.11 java chaincode离线实例化遇到的问题

fabric 1.4.11 java chaincode离线实例化遇到的问题

1. What went wrong: Method com/github/jengelman/gradle/plugins/shadow/internal/DependencyFileCollection.getBuildDependencies()Lorg/gradle/api/tasks/TaskDependency; is abstract

具体报错信息:

root@4e3fba4b5f59:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode instantiate -o orderer0.gzjg.com:7050 --tls --cafile $ORDERER_CA -C gzjgchannel -n gzjgcc -v 1.0 -l java -c '{"Args":["init","a","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
2021-04-14 00:53:14.493 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-04-14 00:53:14.493 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
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: 1 "Copying from /chaincode/input/src/ to /tmp/tmp.qUYN9EbmAO
Gradle build
Downloading https://services.gradle.org/distributions/gradle-5.2.1-bin.zip
...................................................................................

Welcome to Gradle 5.2.1!

Here are the highlights of this release:
 - Define sets of dependencies that work together with Java Platform plugin
 - New C++ plugins with dependency management built-in
 - New C++ project types for gradle init
 - Service injection into plugins and project extensions

For more details see https://docs.gradle.org/5.2.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
Method com/github/jengelman/gradle/plugins/shadow/internal/DependencyFileCollection.getBuildDependencies()Lorg/gradle/api/tasks/TaskDependency; is abstract

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 19s
"

原因:gradle与shadow的版本不兼容,我使用的gradle是5.2.1,使用的shadow版本为2.0.3;它们之间的兼容关系见:https://github.com/johnrengelman/shadow/tree/6.1.0

2.Exception in thread “main” java.net.UnknownHostException: services.gradle.org

具体报错信息:

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: 1 "Copying from /chaincode/input/src/ to /tmp/tmp.GgzoQQKMWg
Gradle build
Downloading https://services.gradle.org/distributions/gradle-5.2.1-bin.zip

Exception in thread "main" java.net.UnknownHostException: services.gradle.org 
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:607)
        at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:284)
        at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
        at sun.net.www.protocol.https.HttpsClient.(HttpsClient.java:264)
        at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1570)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
        at org.gradle.wrapper.Download.downloadInternal(Download.java:67)
        at org.gradle.wrapper.Download.download(Download.java:52)
        at org.gradle.wrapper.Install$1.call(Install.java:62)
        at org.gradle.wrapper.Install$1.call(Install.java:48)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
        at org.gradle.wrapper.Install.createDist(Install.java:48)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:62)

原因(猜测):fabric-javaenv镜像在v1.4.6之后的版本移除了内置的gradle,需要从https://services.gradle.org/distributions/gradle-5.2.1-bin.zip下载gradle进行链码的编译。
解决方案:我的解决办法是创建一个tomcat服务,利用tomcat获取服务器上提前下载好的gradle-5.2.1-bin.zip
tomcat的conf/server.xml文件中添加


在这里插入图片描述
修改chaincode项目中gradle-wrapper.properties的配置

distributionUrl=http://{tomcat服务器IP}:{tomcat服务端口}/download/gradle-5.2.1-bin/7mtpznnc5u8hbuhwyvjxfw40i/gradle-5.2.1-bin.zip

对于第二个问题,具体的原因我也不是特别清楚,搞清楚之后会继续更新。这个问题的解决方案虽然可行,但是个人感觉是个野路子,如果哪位朋友看到这篇博客且有更好的方案,希望不吝赐教,非常感谢!!!

你可能感兴趣的:(hyperledger,fabric,java,区块链,hyperledger,fabric)