Hyperledger Fabric:[Java] ContractException- 交易提交被同级 peer0 拒绝。org2.example.com
Hyperledger Fabric: [Java] ContractException- Transaction commit was rejected by peer peer0.org2.example.com
我正在阅读 Hyperledger Fabric 文档中的商业票据教程,当我尝试使用 Issue 应用程序 (Issue.java) 时遇到 运行时间错误。
https://hyperledger-fabric.readthedocs.io/en/latest/tutorial/commercial_paper.html
我使用了 fabric-samples 的商业票据文件夹中提供的 Java 链码和 Java 应用程序代码。 https://github.com/hyperledger/fabric-samples/tree/main/commercial-paper
我的 OS 是 Debian GNU/Linux 10 (Buster)。
当我运行mvn exec:java -Dexec.mainClass="org.magnetocorp.AddToWallet"
时,成功添加到钱包。
但是当我 运行 mvn exec:java -Dexec.mainClass="org.magnetocorp.Issue"
它产生以下内容:
Read wallet info from: ./wallet
log4j:WARN No appenders could be found for logger (org.hyperledger.fabric.sdk.helper.Config).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Use network channel: mychannel.
Use org.papernet.commercialpaper smart contract.
Submit commercial paper issue transaction.
org.hyperledger.fabric.gateway.ContractException: Transaction commit was rejected by peer peer0.org2.example.com
at org.hyperledger.fabric.gateway.impl.commit.CommitHandlerImpl.onTxEvent(CommitHandlerImpl.java:104)
at org.hyperledger.fabric.gateway.impl.commit.CommitHandlerImpl.access[=12=]0(CommitHandlerImpl.java:26)
at org.hyperledger.fabric.gateway.impl.commit.CommitHandlerImpl.acceptCommit(CommitHandlerImpl.java:33)
at org.hyperledger.fabric.gateway.impl.event.Listeners.lambda$transaction(Listeners.java:122)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.hyperledger.fabric.gateway.impl.event.Listeners.lambda$fromTransaction[=12=](Listeners.java:32)
at org.hyperledger.fabric.sdk.Channel.lambda$null(Channel.java:5974)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
为什么事务提交被拒绝? (以及如何解决此错误?)我们将不胜感激。
假设您使用的是 fabric-gateway-java 的当前 v2.2.x 版本,您应该能够获得一些关于通过检查与该 ContractException 相关联的原因来确定失败的原因。像这样:
Throwable cause = e.getCause();
if (cause instanceof TransactionEventException) {
BlockEvent.TransactionEvent txEvent = ((TransactionEventException) cause).getTransactionEvent();
byte validationCode = txEvent.getValidationCode();
}
验证码值在 Fabric protobuf definitions.
如果验证码表明不符合背书要求,您还可以检查从同行收到的提案响应以背书此交易。提案回复可以是 obtained from the ContractException.
对等日志还可能包含有关失败原因的更多详细信息。
我正在阅读 Hyperledger Fabric 文档中的商业票据教程,当我尝试使用 Issue 应用程序 (Issue.java) 时遇到 运行时间错误。 https://hyperledger-fabric.readthedocs.io/en/latest/tutorial/commercial_paper.html
我使用了 fabric-samples 的商业票据文件夹中提供的 Java 链码和 Java 应用程序代码。 https://github.com/hyperledger/fabric-samples/tree/main/commercial-paper
我的 OS 是 Debian GNU/Linux 10 (Buster)。
当我运行mvn exec:java -Dexec.mainClass="org.magnetocorp.AddToWallet"
时,成功添加到钱包。
但是当我 运行 mvn exec:java -Dexec.mainClass="org.magnetocorp.Issue"
它产生以下内容:
Read wallet info from: ./wallet
log4j:WARN No appenders could be found for logger (org.hyperledger.fabric.sdk.helper.Config).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Use network channel: mychannel.
Use org.papernet.commercialpaper smart contract.
Submit commercial paper issue transaction.
org.hyperledger.fabric.gateway.ContractException: Transaction commit was rejected by peer peer0.org2.example.com
at org.hyperledger.fabric.gateway.impl.commit.CommitHandlerImpl.onTxEvent(CommitHandlerImpl.java:104)
at org.hyperledger.fabric.gateway.impl.commit.CommitHandlerImpl.access[=12=]0(CommitHandlerImpl.java:26)
at org.hyperledger.fabric.gateway.impl.commit.CommitHandlerImpl.acceptCommit(CommitHandlerImpl.java:33)
at org.hyperledger.fabric.gateway.impl.event.Listeners.lambda$transaction(Listeners.java:122)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.hyperledger.fabric.gateway.impl.event.Listeners.lambda$fromTransaction[=12=](Listeners.java:32)
at org.hyperledger.fabric.sdk.Channel.lambda$null(Channel.java:5974)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
为什么事务提交被拒绝? (以及如何解决此错误?)我们将不胜感激。
假设您使用的是 fabric-gateway-java 的当前 v2.2.x 版本,您应该能够获得一些关于通过检查与该 ContractException 相关联的原因来确定失败的原因。像这样:
Throwable cause = e.getCause();
if (cause instanceof TransactionEventException) {
BlockEvent.TransactionEvent txEvent = ((TransactionEventException) cause).getTransactionEvent();
byte validationCode = txEvent.getValidationCode();
}
验证码值在 Fabric protobuf definitions.
如果验证码表明不符合背书要求,您还可以检查从同行收到的提案响应以背书此交易。提案回复可以是 obtained from the ContractException.
对等日志还可能包含有关失败原因的更多详细信息。