0

[リッスンするサービスの取得][1] に関するヘルプを得た後、最初の lagom サービスを実行する以前の試みは失敗しました。

そのため、この試みでは、Maven プロジェクト (usvcs) には 2 つのモジュール (actor-api と actor-impl) と 1 つのサービス コール「echo」しかありません。

public interface MAIActorsService extends Service {
  ServiceCall<NotUsed, String> echo(String s);
  @Override
  default Descriptor descriptor() {
    // @formatter:off
    return named("cmai_actors").withCalls(
            restCall(Method.GET, "/echo/:s", this::echo)
      ).withAutoAcl(true);
    // @formatter:on
  }
}

実装はエンティティ参照を持たないスタブです。

@Override
public ServiceCall<NotUsed, String> echo(String s) {
    return request -> {
        CompletableFuture<String> alreadyCompleted = CompletableFuture.completedFuture(s);
        try {
            alreadyCompleted.get();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return alreadyCompleted;
      };
}

'mvn lagom:runAll' を実行すると、内部ラグム DSL クラスが見つからないことを示す例外がスローされます。

$ mvn lagom:runAll
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] usvcs
[INFO] actor-api
[INFO] actor-impl
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building usvcs 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- lagom-maven-plugin:1.3.0-M1:runAll (default-cli) @ usvcs ---
[INFO] Starting Kafka
[INFO] Starting Cassandra
.[INFO] Did not find Netty's native epoll transport in the classpath, defaulting to NIO.
.........[INFO] Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)
[INFO] New Cassandra host /127.0.0.1:4000 added
[INFO] Cassandra server running at 127.0.0.1:4000
[INFO] Service locator is running at http://localhost:8000
[INFO] Service gateway is running at http://localhost:9000
No play.logger.configurator found: logging must be configured entirely by the application.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\lusp\maisvc\usvcs\actor-api\src\main\resources
[INFO] Nothing to compile - all classes are up to date
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Nothing to compile - all classes are up to date
java.lang.NoClassDefFoundError: com/lightbend/lagom/internal/javadsl/api/broker/TopicFactoryProvider
        at com.lightbend.lagom.internal.javadsl.registry.ServiceRegistryModule.configure(ServiceRegistryModule.scala:35)
        at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
        at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
        at com.google.inject.spi.Elements.getElements(Elements.java:110)
        at com.google.inject.util.Modules$OverrideModule.configure(Modules.java:177)
        at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
        at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
        at com.google.inject.spi.Elements.getElements(Elements.java:110)
        at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
        at com.google.inject.Guice.createInjector(Guice.java:96)
        at com.google.inject.Guice.createInjector(Guice.java:84)
        at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
        at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
        at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
        at play.core.server.LagomReloadableDevServerStart$$anonfun$mainDev$1$$anon$2$$anonfun$get$1$$anonfun$apply$1$$anonfun$2$$anonfun$3.apply(LagomReloadableDevServerStart.scala:151)
        at play.core.server.LagomReloadableDevServerStart$$anonfun$mainDev$1$$anon$2$$anonfun$get$1$$anonfun$apply$1$$anonfun$2$$anonfun$3.apply(LagomReloadableDevServerStart.scala:148)
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
        at play.core.server.LagomReloadableDevServerStart$$anonfun$mainDev$1$$anon$2$$anonfun$get$1$$anonfun$apply$1$$anonfun$2.apply(LagomReloadableDevServerStart.scala:148)
        at play.core.server.LagomReloadableDevServerStart$$anonfun$mainDev$1$$anon$2$$anonfun$get$1$$anonfun$apply$1$$anonfun$2.apply(LagomReloadableDevServerStart.scala:124)
        at scala.Option.map(Option.scala:146)
        at play.core.server.LagomReloadableDevServerStart$$anonfun$mainDev$1$$anon$2$$anonfun$get$1$$anonfun$apply$1.apply(LagomReloadableDevServerStart.scala:124)
        at play.core.server.LagomReloadableDevServerStart$$anonfun$mainDev$1$$anon$2$$anonfun$get$1$$anonfun$apply$1.apply(LagomReloadableDevServerStart.scala:122)
        at scala.util.Success.flatMap(Try.scala:231)
        at play.core.server.LagomReloadableDevServerStart$$anonfun$mainDev$1$$anon$2$$anonfun$get$1.apply(LagomReloadableDevServerStart.scala:122)
        at play.core.server.LagomReloadableDevServerStart$$anonfun$mainDev$1$$anon$2$$anonfun$get$1.apply(LagomReloadableDevServerStart.scala:114)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
        at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.ClassNotFoundException: com.lightbend.lagom.internal.javadsl.api.broker.TopicFactoryProvider
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 33 more

Stacktrace caused by project target (filesystem path to project is C:\Users\lusp\maisvc\usvcs\actor-impl\target).

[INFO] Service actor-impl listening for HTTP on 0:0:0:0:0:0:0:0:62728
[INFO] (Service started, press enter to stop and go back to the console...)

サービスが機能せず、明らかな問題は、サービス呼び出しのスタブ化が許可されていないかどうかです???

アップデート

いくつかの変更を加えましたが、まだエラーが発生したため、コードを github に掲載して、より完全に文書化しましたhttps://github.com/tevye/lagom-echo-project-from-scratch

4

1 に答える 1