在[获取服务监听] [1]获得帮助后,先前尝试运行初始lagom服务失败。
因此,在这次尝试中,maven项目(usvcs)只有两个模块(actor-api和actor-impl)和一个服务调用'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'抛出异常,说明找不到内部 lagom 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
答案 0 :(得分:1)
似乎你有maven dep问题。 在父pom.xml中,您有:
<lagom.version>1.3.0-M1</lagom.version>
此版本由lagom maven插件使用。
另一方面,所有lagom依赖项都使用版本1.2.1:
<dependency>
<groupId>com.lightbend.lagom</groupId>
<artifactId>lagom-javadsl-persistence_2.11</artifactId>
<version>1.2.1</version>
</dependency>
尝试将其更改为:
<dependency>
<groupId>com.lightbend.lagom</groupId>
<artifactId>lagom-javadsl-persistence_2.11</artifactId>
<version>${lagom.version}</version>
</dependency>
为所有其他lagom deps做。
你的另一个问题似乎是2个持久性提供者
<dependency>
<groupId>com.lightbend.lagom</groupId>
<artifactId>lagom-javadsl-persistence-jdbc_2.11</artifactId>
</dependency>
<dependency>
<groupId>com.lightbend.lagom</groupId>
<artifactId>lagom-javadsl-persistence-cassandra_2.11</artifactId>
</dependency>
从pom(s).xml中删除依赖关系: lagom-javadsl-persistence-jdbc_2.11 (特别是actor-impl / pom.xml)
此外,您不需要在actor-api / pom.xml中使用其中任何一个 从 com.lightbend.lagom 只留下 lagom-javadsl-api_2.11