正在运行超级账本结构Java网关示例代码抛出必须设置网关标识

问题描述 投票:1回答:1

我正在尝试在基本网络上编写结构网关应用程序,我的代码如下所示。


     public static void main(String[] args) throws Exception {
       // Load a file system based wallet for managing identities.
       Path walletPath = Paths.get("wallet");
       Wallet wallet = Wallet.createFileSystemWallet(walletPath);

       // load a CCP
       Path networkConfigPath = Paths.get("..", "..", "basic-network", "connection.yaml");

       Gateway.Builder builder = Gateway.createBuilder();
       builder.identity(wallet, "user1");
       builder.networkConfig(networkConfigPath).discovery(true);

       // create a gateway connection
       try (Gateway gateway = builder.connect()) {
          System.out.println("Hello");
       }
       catch(Exception e) {
          e.printStackTrace();
     }
   }

当我运行代码时,它会引发错误

Exception in thread "main" java.lang.IllegalStateException: The gateway identity must be set

请帮助我找到如何设置此网络的身份?

我的connection.yaml为

name: basic-network
version: 1.0.0
client:
    organization: Org1
    connection:
        timeout:
            peer:
                endorser: '300'
            orderer: '300'
channels:
    mychannel:
        orderers:
        - orderer.example.com
        peers:
            peer0.org1.example.com: {}
organizations:
    Org1:
        mspid: Org1MSP
        peers:
        - peer0.org1.example.com
        certificateAuthorities:
        - ca.example.com
orderers:
    orderer.example.com:
        url: grpc://localhost:7050
peers:
    peer0.org1.example.com:
        url: grpc://localhost:7051
certificateAuthorities:
    ca.example.com:
        url: http://localhost:7054
        caName: ca.example.com

[email protected]中有一个名为basic-network/crypto-config/peerOrganizations/org1.example.com/users/的文件夹>

我正在尝试在基本网络上编写一个Fabric网关应用,我的代码如下所示。公共静态void main(String [] args)引发异常{//为...加载基于文件系统的钱包...

hyperledger-fabric hyperledger-fabric-sdk-java
1个回答
0
投票

好吧,我了解您的问题。您从结构样本中错误地运行了fabcar示例。

© www.soinside.com 2019 - 2024. All rights reserved.