아래 문서를 참고하여 Ubuntu에서 Indy SDK Java 예제를 빌드하고 실행하는 실습을 진행합니다.
1. 실습 환경
- Windows 10
- Oracle VM VirtualBox 6.1.6
- 가상 머신 생성
- 이름:
ubuntu-indy
- 메모리 크기:
4
GB - 저장소 크기:
40
GB (10
GB로 하면 금방 부족해짐)
- 이름:
- 가상 머신 생성
- Ubuntu Desktop 20.04 LTS
2. Java 빌드 프로그램 설치
-
Java SDK를 설치합니다.
$ sudo apt-get install openjdk-8-jdk
-
Maven을 설치합니다.
$ sudo apt-get install maven
3. Java 예제 빌드
-
Indy SDK 소스를 다운로드합니다.
$ cd $HOME $ git clone https://github.com/hyperledger/indy-sdk.git
-
Java 예제를 빌드합니다.
$ cd $HOME/indy-sdk/samples/java $ mvn package
4. 테스트
-
Indy 노드 풀을 실행합니다.
$ cd $HOME/indy-sdk $ docker build -f ci/indy-pool.dockerfile -t indy_pool . $ docker run -itd -p 9701-9708:9701-9708 indy_pool
-
Java 예제를 실행합니다.
$ mvn exec:java -Dexec.mainClass=Main
정상적인 실행 결과는 아래와 같은 메시지를 출력합니다.
Anoncreds sample -> started SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Anoncreds sample -> completed Anoncreds Revocation sample -> started Anoncreds Revocation sample -> completed Ledger sample -> started Ledger sample -> completed Crypto sample -> started Crypto sample -> completed Endorser sample -> started Endorser sample -> completed
Indy 노드 풀이 실행중이 아닐 경우 아래와 같은
TimeoutException
오류 메시지가 출력됩니다.Anoncreds sample -> started SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. [WARNING] java.util.concurrent.ExecutionException: org.hyperledger.indy.sdk.ledger.TimeoutException: Timeout happens for ledger operation. at java.util.concurrent.CompletableFuture.reportGet (CompletableFuture.java:395) at java.util.concurrent.CompletableFuture.get (CompletableFuture.java:1999) at Anoncreds.demo (Anoncreds.java:27) at Main.main (Main.java:4) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282) at java.lang.Thread.run (Thread.java:834) Caused by: org.hyperledger.indy.sdk.ledger.TimeoutException: Timeout happens for ledger operation. at org.hyperledger.indy.sdk.IndyException.fromSdkError (IndyException.java:164) at org.hyperledger.indy.sdk.IndyJava$API.checkResult (IndyJava.java:92) at org.hyperledger.indy.sdk.pool.Pool.access$100 (Pool.java:20) at org.hyperledger.indy.sdk.pool.Pool$1.callback (Pool.java:52) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback (CallbackReference.java:520) at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback (CallbackReference.java:551) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------
-
Indy 노드 풀 주소를
TEST_POOL_ID
환경변수에 지정하여 Java 예제를 실행할 수 있습니다.export TEST_POOL_IP=192.168.56.110 $ mvn exec:java -Dexec.mainClass=Main
이전에 다른 주소의 Indy 노드 풀에 접근하다가 실패한 적이 있다면 위와 같이 주소를 변경하여 실행할 때 아래와 같은
PoolLedgerConfigExistsException
오류 메시지가 발생할 수 있습니다.Anoncreds sample -> started SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. [WARNING] java.util.concurrent.ExecutionException: org.hyperledger.indy.sdk.pool.PoolLedgerConfigExistsException: A pool ledger configuration already exists with the specified name. at java.util.concurrent.CompletableFuture.reportGet (CompletableFuture.java:395) at java.util.concurrent.CompletableFuture.get (CompletableFuture.java:1999) at utils.PoolUtils.createPoolLedgerConfig (PoolUtils.java:48) at Anoncreds.demo (Anoncreds.java:26) at Main.main (Main.java:4) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282) at java.lang.Thread.run (Thread.java:834) Caused by: org.hyperledger.indy.sdk.pool.PoolLedgerConfigExistsException: A pool ledger configuration already exists with the specified name. at org.hyperledger.indy.sdk.IndyException.fromSdkError (IndyException.java:162) at org.hyperledger.indy.sdk.IndyJava$API.checkResult (IndyJava.java:92) at org.hyperledger.indy.sdk.pool.Pool.access$400 (Pool.java:20) at org.hyperledger.indy.sdk.pool.Pool$2.callback (Pool.java:70) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback (CallbackReference.java:520) at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback (CallbackReference.java:551) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------
이럴 경우에는
$HOME/.indy_client
폴더를 지우고 다시 실행합니다.
Written with StackEdit.
댓글 없음:
댓글 쓰기