Updated on 2022-11-16 GMT+08:00

Checking the Java SDK Application Demo

Fault Locating

  1. Check whether the BCS instance is named java-sdk-demo, uses the Enterprise edition if the security mechanism is OSCCA-published cryptographic algorithms, is a private blockchain deployed in a CCE cluster, and uses SOLO for the consensus mechanism.

    Ensure that the development tools have been correctly installed and configured. For details, see Preparation.

    To check these details, log in to the BCS console, go to the Instance Management page, and click the target instance to view its details. For details about the configurations required for this demo, see Java SDK Demo.

  1. Check whether the orderer and peer certificates have been downloaded, and whether the SDK file (java-sdk-demo-sdk-config.zip) has been downloaded to the config directory of the demo project. For details, see sections "Download the SDK configuration" and "Download certificates" under Configuring the Application.

    The chaincode name specified when you set the SDK file parameters must be the same as that specified during chaincode installation.

  2. Check whether the path of the Main class has been changed as required. For details, see Deploying the Application.

    Find the Main.java file in the /javasdkdemo/src/main/java/handler/ directory, and change the file path in the following code of the Main class to the absolute path of the java-sdk-demo-sdk-config.yaml file. Change the backslashes (\) to slashes (/).

    helper.setConfigCtx("E:/yourdir/huawei.yaml");

  3. If the BCS instance uses OSCCA-published cryptographic algorithms, check whether the dependency upon fabric-sdk-java-1.4.1-jar-with-dependencies.jar is added to pom.xml. To add the dependency, remove the comments on the dependency as shown in the following figure.

  4. If timeout occurs occasionally and the transaction interval is long, check whether the fault is caused by the connection protection mechanism of a third-party gRPC. The following figure shows the error information.

Solution

In the src\main\java\handler\FabricHelper.java file, add p.put to the sample code as shown in the following figure. Save the code and perform the transaction again.

p.put("grpc.NettyChannelBuilderOption.keepAliveTime", new Object[] {5L, TimeUnit.MINUTES});

p.put("grpc.NettyChannelBuilderOption.keepAliveTimeout", new Object[] {8L, TimeUnit.SECONDS});

p.put("grpc.NettyChannelBuilderOption.keepAliveWithoutCalls", new Object[] {true});

p.put("grpc.NettyChannelBuilderOption.maxInboundMessageSize", 102400000);

Demo Problems FAQs

more