简体   繁体   English

Ledger API入门

[英]Getting Started with the Ledger API

I am working through Getting started with the Digital Asset Ledger API . 我正在通过Digital Asset Ledger API入门 I was careful to follow the direction to Configure Maven to work with the Digital Asset Repository Creating the ping-pong-java project, and compiling it with 'maven' and running 'sandbox' worked w/oa problem. 我很谨慎地遵循将Maven配置为与数字资产存储库一起使用的指示信息创建ping-pong-java项目,并使用“ maven”进行编译并运行“ sandbox”,但没有出现问题。 However, entering: 但是,输入:

mvn exec:java

causes the following output: 导致以下输出:

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building example-ping-pong-grpc-java 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ example-ping-pong-grpc-java ---
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.lang.RuntimeException: Module PingPong is not available on the ledger
    at examples.pingpong.PingPongMain.detectPingPongPackageId (PingPongMain.java:194)
    at examples.pingpong.PingPongMain.main (PingPongMain.java:63)
    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:564)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
    at java.lang.Thread.run (Thread.java:844)
[WARNING] thread Thread[grpc-default-worker-ELG-1-1,5,examples.pingpong.PingPongMain] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[grpc-default-worker-ELG-1-1,5,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] thread Thread[grpc-default-executor-0,5,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] thread Thread[ObjectCleanerThread,1,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] thread Thread[grpc-default-worker-ELG-1-2,5,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] thread Thread[grpc-default-worker-ELG-1-3,5,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] thread Thread[grpc-default-worker-ELG-1-4,5,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] thread Thread[grpc-default-worker-ELG-1-5,5,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] thread Thread[grpc-default-worker-ELG-1-6,5,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] thread Thread[grpc-default-worker-ELG-1-7,5,examples.pingpong.PingPongMain] will linger despite being asked to die via interruption
[WARNING] NOTE: 9 thread(s) did not finish despite being asked to  via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=examples.pingpong.PingPongMain,maxpri=10]
java.lang.IllegalThreadStateException
    at java.lang.ThreadGroup.destroy (ThreadGroup.java:776)
    at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:321)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.860 s
[INFO] Finished at: 2019-02-25T15:45:02-05:00
[INFO] Final Memory: 12M/57M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project example-ping-pong-grpc-java: An exception occured while executing the Java class. Module PingPong is not available on the ledger -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I following the link in the error message http://www.slf4j.org/codes.html#StaticLoggerBinder and it says there as follows: 我按照错误消息http://www.slf4j.org/codes.html#StaticLoggerBinder中的链接进行操作,并显示以下内容:

Failed to load class org.slf4j.impl.StaticLoggerBinder
This warning message is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

SINCE 1.6.0 As of SLF4J version 1.6, in the absence of a binding, SLF4J will default to a no-operation (NOP) logger implementation.

If you are responsible for packaging an application and do not care about logging, then placing slf4j-nop.jar on the class path of your application will get rid of this warning message. Note that embedded components such as libraries or frameworks should not declare a dependency on any SLF4J binding but only depend on slf4j-api. When a library declares a compile-time dependency on a SLF4J binding, it imposes that binding on the end-user, thus negating SLF4J's purpose. 

I don't know what to make of all this. 我不知道该怎么办。 I only want to follow this tutorial to understand the API ledger. 我只想按照本教程来了解API分类帐。 I am not experienced with java or maven and I'm not planning on learning them since my Ledger application needs to be written in PHP. 我没有Java或Maven的经验,我也不打算学习它们,因为我的Ledger应用程序需要用PHP编写。 What do I need to do to get around this error? 我该怎么办才能解决此错误?

I think the red stack trace is a bit of a red herring, and the important message is the RuntimeException thrown from examples.pingpong.PingPongMain.detectPingPongPackageId (PingPongMain.java:194) - that indicates that the Java code can't find the DAML model code that should be loaded into ledger (sandbox). 我认为红色堆栈跟踪有点像红色鲱鱼,重要的消息是从examples.pingpong.PingPongMain.detectPingPongPackageId (PingPongMain.java:194)抛出的RuntimeException-表示Java代码找不到DAML。应该加载到分类帐(沙箱)中的模型代码。 Did you run da sandbox ? 您运行da sandbox吗? Try again and make sure the sandbox is running. 再试一次,确保沙箱正在运行。 Also check your da.yaml to make sure it is there, and looks something like this: 还要检查您的da.yaml以确保它在那里,并且看起来像这样:

project:
  sdk-version: 0.11.3
  name: PingPongExample
  source: daml/PingPong.daml
  parties:
  - Alice
  - Bob
version: 2

If your ledger server (sandbox) runs correctly you should see this printed to the terminal: 如果您的分类帐服务器(沙盒)正常运行,则应该在终端上看到此打印:

paul:ping-pong-java$ da sandbox
[Info] Starting:
    Sandbox ledger server /Users/paul/dev/ping-pong-java/daml/PingPong.daml
    with no scenario and binding to port 7600

2019-02-26 14:14:50.09 [DEBUG]  [package]  []  [DA.Service.Daml.Compiler.Impl.Handle:245] 
Creating dar: /Users/paul/dev/ping-pong-java/daml/PingPong.daml

2019-02-26 14:14:50.09 [DEBUG]  [package]  []  [DA.Service.Daml.Compiler.Impl.Handle:171] 
Setting files of interest to: [AbsoluteFilePath {getRawFilePath = "/Users/paul/dev/ping-pong-java/daml/PingPong.daml"}]

2019-02-26 14:14:50.09 [INFO]   [package]  [] 
Starting shakeRun (aborting the previous one took 0.00s)

2019-02-26 14:14:50.09 [DEBUG]  [package]  []  [DA.Service.Daml.Compiler.Impl.Handle:217] 
Compiling: /Users/paul/dev/ping-pong-java/daml/PingPong.daml

2019-02-26 14:14:50.09 [INFO]   [package]  [] 
Finishing shakeRun (took 0.00s, exception)

2019-02-26 14:14:50.09 [INFO]   [package]  [] 
Starting shakeRun (aborting the previous one took 0.00s)

2019-02-26 14:14:51.17 [INFO]   [package]  [] 
Finishing shakeRun (took 1.08s, completed)

2019-02-26 14:14:51.17 [INFO]   [package]  [] 
Starting shakeRun (aborting the previous one took 0.00s)

2019-02-26 14:14:51.17 [INFO]   [package]  [] 
Finishing shakeRun (took 0.00s, completed)
Created /Users/paul/dev/ping-pong-java/target/PingPongExample.dar.
Created /Users/paul/dev/ping-pong-java/target/ghc-prim.dalf.
Waiting for Sandbox.......ok

I'm assuming you are running the latest version of the SDK (0.11.3). 我假设您正在运行最新版本的SDK(0.11.3)。 Please upgrade if you are not. 如果不是,请升级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM