您的位置:首页 > 房产 > 建筑 > Ubuntu22.04 解决fabric 安装gradle构建的Java合约超时

Ubuntu22.04 解决fabric 安装gradle构建的Java合约超时

2024/12/23 11:10:04 来源:https://blog.csdn.net/NF_ALONG/article/details/140867756  浏览:    关键词:Ubuntu22.04 解决fabric 安装gradle构建的Java合约超时

问题

fabric安装gradle构建的Java合约时遇到合约代码编译超时问题,如下:

$ peer lifecycle chaincode install cp.tar.gz 
Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "+ INPUT_DIR=/chaincode/input
+ OUTPUT_DIR=/chaincode/output
++ mktemp -d
+ TMP_DIR=/tmp/tmp.QxEGc5qu3R
++ find /chaincode/input -name '*.jar'
++ wc -l
+ NUM_JARS=1
+ for DIR in ${INPUT_DIR} ${INPUT_DIR}/src
+ '[' -f /chaincode/input/build.gradle -o -f /chaincode/input/build.gradle.kts ']'
+ '[' -f /chaincode/input/pom.xml ']'
+ for DIR in ${INPUT_DIR} ${INPUT_DIR}/src
+ '[' -f /chaincode/input/src/build.gradle -o -f /chaincode/input/src/build.gradle.kts ']'
+ buildGradle /chaincode/input/src /chaincode/output
+ echo 'Copying from /chaincode/input/src to /tmp/tmp.QxEGc5qu3R'
+ cd /chaincode/input/src
+ tar cf - .
+ cd /tmp/tmp.QxEGc5qu3R
+ tar xf -
Copying from /chaincode/input/src to /tmp/tmp.QxEGc5qu3R
+ cd /tmp/tmp.QxEGc5qu3R
+ echo 'Gradle build'
+ '[' -f ./gradlew ']'
+ chmod +x ./gradlew
Gradle build
+ ./gradlew build shadowJar -x test
Downloading https://services.gradle.org/distributions/gradle-6.5.1-bin.zipException in thread "main" java.net.ConnectException: Connection timed out (Connection timed out)at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)at java.base/java.net.Socket.connect(Socket.java:609)at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:509)at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:604)at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:910)at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:724)at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1637)at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1542)at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)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:63)
"

在logspout中输出为:
在这里插入图片描述
由此看到是下载https://services.gradle.org/distributions/gradle-6.5.1-bin.zip文件超时。

解决方案

替换镜像地址

把https://services.gradle.org/distributions/gradle-6.5.1-bin.zip替换成https://mirrors.cloud.tencent.com/gradle/gradle-6.5.1-bin.zip。

即 https://mirrors.cloud.tencent.com/gradle/{版本号}。

修改配置

修改Java工程目录下的gradle/wrapper/gradle-wrapper.properties文件,把distributionUrl=https://services.gradle.org/distributions/gradle-6.5.1-bin.zip 替换成 distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-6.5.1-bin.zip

替换后重新操作 链码打包 和安装流程。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com