I'm going through the commercial paper tutorial in the Hyperledger Fabric docs, and I'm getting a runtime error when I try to use the Issue application (Issue.java). https://hyperledger-fabric.readthedocs.io/en/latest/tutorial/commercial_paper.html
I've used the Java chaincode and Java application code given in the commercial paper folder of fabric-samples. https://github.com/hyperledger/fabric-samples/tree/main/commercial-paper
My OS is Debian GNU/Linux 10 (Buster).
When I run mvn exec:java -Dexec.mainClass="org.magnetocorp.AddToWallet"
, it successfully adds to the wallet.
But when I run mvn exec:java -Dexec.mainClass="org.magnetocorp.Issue"
it yields the following:
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$000(CommitHandlerImpl.java:26)
at org.hyperledger.fabric.gateway.impl.commit.CommitHandlerImpl$1.acceptCommit(CommitHandlerImpl.java:33)
at org.hyperledger.fabric.gateway.impl.event.Listeners.lambda$transaction$7(Listeners.java:122)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.hyperledger.fabric.gateway.impl.event.Listeners.lambda$fromTransaction$0(Listeners.java:32)
at org.hyperledger.fabric.sdk.Channel.lambda$null$12(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)
Why was the transaction commit rejected? (And how do I resolve this error?) Any help would be much appreciated.
Assuming you are using a current v2.2.x version of fabric-gateway-java, you should be able to get at some information about the reason for the failure by inspecting the cause linked to that ContractException. Something like this:
Throwable cause = e.getCause();
if (cause instanceof TransactionEventException) {
BlockEvent.TransactionEvent txEvent = ((TransactionEventException) cause).getTransactionEvent();
byte validationCode = txEvent.getValidationCode();
}
The validation code values are in the Fabric protobuf definitions.
You can also inspect the proposal responses received from peers to endorse this transaction if the validation code indicates that the endorsement requirements were not met. The proposal responses can be obtained from the ContractException.
The peer logs may also contain more detail about the reason for the failure.