The Akka gRPC QuickStart can't run

Environment

  • Windows 11
  • Java 11
  • Scala 2.13.4
  • Akka 2.8.0
  • IDEA 2023.1

Project

I modified nothing about the official project. The guide shows command of compile and run.

  • Compile: sbt compile
  • Run: sbt runMain com.example.helloworld.GreeterServer

Error Log

[info] running (fork) com.example.helloworld.GreeterServer
[info] [2023-04-15 12:13:36,854] [INFO] [akka.event.slf4j.Slf4jLogger] [GreeterServer-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
[error] Exception in thread "main" java.lang.NoClassDefFoundError: akka/parboiled2/ParserInput
[error]         at akka.http.scaladsl.model.headers.User$minusAgent$.apply(headers.scala:1094)
[error]         at akka.http.impl.settings.ClientConnectionSettingsImpl$.$anonfun$fromSubConfig$1(ClientConnectionSettingsImpl.scala:58)
[error]         at scala.Option.map(Option.scala:242)
[error]         at akka.http.impl.settings.ClientConnectionSettingsImpl$.fromSubConfig(ClientConnectionSettingsImpl.scala:58)
[error]         at akka.http.impl.settings.ConnectionPoolSettingsImpl$.fromSubConfig(ConnectionPoolSettingsImpl.scala:102)
[error]         at akka.http.impl.settings.ConnectionPoolSettingsImpl$.fromSubConfig(ConnectionPoolSettingsImpl.scala:88)
[error]         at akka.http.impl.util.SettingsCompanionImpl.apply(SettingsCompanionImpl.scala:51)
[error]         at akka.http.scaladsl.settings.ConnectionPoolSettings$.apply(ConnectionPoolSettings.scala:97)
[error]         at akka.http.scaladsl.settings.ConnectionPoolSettings$.apply(ConnectionPoolSettings.scala:87)
[error]         at akka.http.scaladsl.settings.SettingsCompanion.apply(SettingsCompanion.scala:19)
[error]         at akka.http.scaladsl.settings.SettingsCompanion.apply$(SettingsCompanion.scala:19)
[error]         at akka.http.scaladsl.settings.ConnectionPoolSettings$.apply(ConnectionPoolSettings.scala:87)
[error]         at akka.http.scaladsl.HttpExt.<init>(Http.scala:84)
[error]         at akka.http.scaladsl.Http$.createExtension(Http.scala:1112)
[error]         at akka.http.scaladsl.Http$.createExtension(Http.scala:846)
[error]         at akka.actor.ActorSystemImpl.registerExtension(ActorSystem.scala:1187)
[error]         at akka.actor.ExtensionId.apply(Extension.scala:78)
[error]         at akka.actor.ExtensionId.apply$(Extension.scala:77)
[error]         at akka.http.scaladsl.Http$.apply(Http.scala:1107)
[error]         at akka.http.scaladsl.Http$.apply(Http.scala:846)
[error]         at akka.actor.ExtensionId.apply(Extension.scala:84)
[error]         at akka.actor.ExtensionId.apply$(Extension.scala:84)
[error]         at akka.http.scaladsl.Http$.apply(Http.scala:1106)
[error]         at akka.http.scaladsl.Http$.apply(Http.scala:846)
[error]         at com.example.helloworld.GreeterServer.run(GreeterServer.scala:55)
[error]         at com.example.helloworld.GreeterServer$.main(GreeterServer.scala:42)
[error]         at com.example.helloworld.GreeterServer.main(GreeterServer.scala)
[error] Caused by: java.lang.ClassNotFoundException: akka.parboiled2.ParserInput
[error]         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
[error]         at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
[error]         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
[error]         ... 27 more

Another Problem about the Akka gRPC plugin.

I posted it before.

It’s my confusion:

  1. Why can only running the command sbt compile in terminal compile the .proto files, but not “Build Project” in IDEA?
  2. Why can’t the IDEA import the compiling result of .proto, event now in the official project?

Thanks.

I find a way like this:

  1. it must compile the .proto with the command sbt compile at first.
  2. then, it must reload the changes of build.sbt one time, or the result of compiling can’t take effect.
  3. now, the IDEA editor can recognize the traits and case classes built from .proto when I type them manually.
  4. at last, use the command sbt compile to compile the project, but not the “Build Project” command of IDEA, or you will get the error: XXX is already defined as case class XXX and XXX is already defined as trait XXX

I think that the Akka gRPC plugin is not compatible with the IDEA. And I suppose that the ScalaTest conflicts with it because all import statements of ScalaTest in test files change to grey, the editor shows can not resolve symbol AnyFeatureSpecLike.

I am devastated by this question! Help me, please.

Your first problem I cannot reproduce, downloading the zip and running sbt compile followed by sbt "runMain com.example.helloworld.GreeterServer" with JDK 11 starts up fine. Parboiled is mirrored in the Akka HTTP artifacts (the akka-parsing jar more specifically), so it is very strange that it would be missing in your classpath. Note sure what could be going on there.

I don’t have access to a Windows machine though, so cannot try it out in something closer to your environment.

I found a separate issue with the quickstart though, and that is that the sample shipped TLS cert is broken, I’ve created an issue to track that: Quickstart TLS cert broken · Issue #1769 · akka/akka-grpc · GitHub

For the IntelliJ side of things, I’m not sure why IntelliJ doesn’t always pick up the directories where sources are generated (or exactly what sbt task “Build Project” maps to) but I have noticed that it can help to first do a sbt compile before trying to open up the project in IntelliJ so that the generated directories exist, or triggering that from the sbt shell inside IntelliJ.

I may be wrong but I think this is a shortcoming of the sbt integration in IntelliJ rather than something specific about the Akka gRPC plugin (which does list the directories it generate code to with sbt managedSourceDirectories settings etc.).

Thank you very much.

About quick start project

At first, I tested the quick start project on Debian with the terminal command, but not IDEA. it works!!!

Secondly, I ran it with IDEA. it works again.

About the gRPC plugin and SBT

I tried to open the project with IDEA on Debian and edit the GreeterServiceImpl.scala. Everything goes well.

Oh my GOD! I don’t know what’s the matter with my Windows system. It’s a painful day for me!

I printed the Akka Platform Guide last year and read it more times, then added notes and updated it later. But I still missed something about the Akka.

Thanks for your help again.

Today, I deleted the directories .ivy2, .m2,.idea-build and .sbt in my user folder on Windows. Then re-installed the IDEA 2023.1. Now, the project runs well. The exception akka/parboiled2/ParserInput doesn’t happen again.

I suppose that the packages cached maybe were damaged.