Closed zhuangjinxin closed 6 years ago
Run 运行打印日志:
the path: /Users/xxx/Projects/BlockChain/samples/projects/java/sample/bin/../res/config.json
the config file:
{
"rpc_host" : "192.168.7.100",
"rpc_port" : 8545,
"contract_binary": "6060604052341561000c57fe5b5b60056000819055505b5b60c6806100256000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a72305820df8a57eee7fa3751dd1a8cc753a935ac3cdd07b391e14b64c76b42b3389715950029",
"contract_abi" : [{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"_ret","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"}],
"wallet" : "wallet.json",
"password" : "1111"
}
the config: org.bcos.sample.app.BcosConfig@73a8dfcc
the wallet: /Users/xxx/Projects/BlockChain/samples/projects/java/sample/bin/../res/wallet.json
address: 0x03aa3e823cb7899b7b589ea242cdc2f26717d5fc
load configure successully !
停留一会儿(74秒)之后,报错:
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: org.apache.http.conn.HttpHostConnectException: Connect to 192.168.7.100:8545 [/192.168.7.100] failed: Operation timed out (Connection timed out)
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at org.bcos.sample.app.BcosApp.deployContract(BcosApp.java:133)
at org.bcos.sample.app.Main.main(Main.java:22)
Caused by: java.util.concurrent.ExecutionException: org.apache.http.conn.HttpHostConnectException: Connect to 192.168.7.100:8545 [/192.168.7.100] failed: Operation timed out (Connection timed out)
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at org.bcos.web3j.tx.BcosRawTxManager.getNonce(BcosRawTxManager.java:72)
at org.bcos.web3j.tx.BcosRawTxManager.sendTransaction(BcosRawTxManager.java:82)
at org.web3j.tx.TransactionManager.executeTransaction(TransactionManager.java:44)
at org.web3j.tx.ManagedTransaction.send(ManagedTransaction.java:39)
at org.web3j.tx.Contract.executeTransaction(Contract.java:169)
at org.web3j.tx.Contract.create(Contract.java:262)
at org.web3j.tx.Contract.deploy(Contract.java:255)
at org.web3j.tx.Contract.lambda$deployAsync$5(Contract.java:288)
at org.web3j.utils.Async.lambda$run$23(Async.java:20)
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626)
at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1618)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 192.168.7.100:8545 [/192.168.7.100] failed: Operation timed out (Connection timed out)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:158)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
at org.web3j.protocol.http.HttpService.send(HttpService.java:63)
at org.web3j.protocol.Service.lambda$sendAsync$17(Service.java:21)
... 7 more
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
... 20 more
*** deploy contract failed ***
error in deploy contract !!!
@黄高峰-矩阵元-深圳 链接超时,你可以在浏览器输入地址端口试试,是不是服务节点没起来,或防火墙配置不对
连接超时,防火墙设置的问题;systemctl stop firewalld.service
关闭防火墙。
如果节点正常启动,在浏览器中访问地址:端口
,会提示Not allowed HTTP Method
.
正常启动的日志:
the path: /Users/xxx/Projects/BlockChain/samples/projects/java/sample/bin/../res/config.json
the config file:
{
"rpc_host" : "192.168.7.100",
"rpc_port" : 8545,
"contract_binary": "6060604052341561000c57fe5b5b60056000819055505b5b60c6806100256000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a72305820df8a57eee7fa3751dd1a8cc753a935ac3cdd07b391e14b64c76b42b3389715950029",
"contract_abi" : [{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"_ret","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"}],
"wallet" : "wallet.json",
"password" : "1111"
}
the config: org.bcos.sample.app.BcosConfig@6cc4c815
the wallet: /Users/xxx/Projects/BlockChain/samples/projects/java/sample/bin/../res/wallet.json
address: 0x03aa3e823cb7899b7b589ea242cdc2f26717d5fc
load configure successully !
deploy SimpleStorage success, address: 0x84e9ce955d6d4db0bd38d98f8f94cf7cb3b53cc5
execute SimpleStorage transaction success, TxHash: 0xb71bbc695e8a387963ba11d364fbdc71b948167a278bd82c0ddfa10363250869
get the log: info: verify, address: 0x03aa3e823cb7899b7b589ea242cdc2f26717d5fc
the call value: 1000
项目导入过程:
打开Eclipse,
File
->Import
->General
->Existing Project into Workspace
->选择sample
项目->Finish
完成!问题1:
问题描述:导入后一片红,缺少web3j的main包和extension包! 解决办法: 右击项目名
sample
->Build Path
->Configure Build Path...
->选Libraries
->Add JARs
->选择sample项目sample/lib
目录下的三个包:DfsSDK.jar
、web3j-2.1.0.jar
和web3j-2.1.0-extension.jar
点Ok
->点Apply
应用->点Ok
确认;项目里的红杠消除,依赖包全部导入!问题2:
问题描述: 运行项目报错
The project: web3j-v2.0.1_src which is referenced by the classpath, does not exist.
解决办法: 右键项目名simple
->Build Path
->Configure Build Path
->Projects
->removeweb3j
相关的两个项目->Ok
确认!之后,再Run运行Main.java即可!
提供给官方的解决办法:
https://github.com/bcosorg/samples/issues/1