Skip to content

zamrokk/fabric-sdk-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java SDK for Hyperledger Fabric

Welcome to Java SDK for Hyperledger project. This is a summary of steps required to get you started with building and using the Java SDK. Please note that this is not the API documentation or a tutorial for the SDK, this will only help you familiarize to get started with the SDK if you are new in this domain.

Compiling

To build this project, following dependencies must be met

  • JDK 1.8 or above
  • Apache Maven

Once your JAVA_HOME points to your installation of JDK 1.8 (or above) and JAVA_HOME/bin and Apache maven are in your PATH, issue the following command to build the jar file: mvn install or mvn install -DskipTests if you don't want to run the unit tests

Running the unit tests

To run the unit tests, please use mvn test or mvn install which will run the unit tests and build the jar file. You must be running a local instance of membersrvcs and a peer to be able to run the unit tests. Please follow the instructions here to setup the development environment.

Using the SDK

To use the SDK in your code, simply add the generated JAR file in your classpath. Once the JAR file is in your classpath, create a chain instance to interact with the network.
Chain testChain = new Chain("chain1");

Add the membership service:
testChain.setMemberServicesUrl("grpc://localhost:7054", null);

Set a keyValueStore:
testChain.setKeyValStore(new FileKeyValStore(System.getProperty("user.home")+"/test.properties"));

Add a peer to the chain:
testChain.addPeer("grpc://localhost:7051", null);

Get a member:
Member registrar = testChain.getMember("admin");

Enroll a member:
Member member = testChain.enroll("user", "secret");

SDK dependencies

SDK depends on few third party libraries that must be included in your classpath when using the JAR file. To get a list of dependencies, refer to pom.xml file or run mvn dependency:tree or mvn dependency:list.

Alternatively, mvn dependency:analyze-report will produce a report in HTML format in target directory listing all the dependencies in a more readable format.

#Basic Troubleshooting identity or token do not match

Keep in mind that you can perform the enrollment process with the membership services server only once, as the enrollmentSecret is a one-time-use password. If you have performed a user registration/enrollment with the membership services and subsequently deleted the crypto tokens stored on the client side, the next time you try to enroll, errors similar to the ones below will be seen.

Error: identity or token do not match

Error: user is already registered

To address this, remove any stored crypto material from the CA server by following the instructions here which typically involves deleting the /var/hyperledger/production directory and restarting the membership services. You will also need to remove any of the crypto tokens stored on the client side by deleting the KeyValStore . That KeyValStore is configurable and is set to ${user.home}/test.properties within the unit tests.

When running the unit tests, you will always need to clean the membership services database, and delete the KeyValStore file, otherwise the unit tests will fail.

java.security.InvalidKeyException: Illegal key size

If you get this error, this means your JDK does not capable of handling unlimited strength crypto algorithms. To fix this issue, You will need to download the JCE libraries for your version of JDK. Please follow the instructions here to download and install the JCE for your version of the JDK.

About

own fork of fabric-sdk-java from org.hyperledger

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published