How to run the akka grpc java example

jteichert :

Ok, following the prerequisites and instructions to use Java 8 the project creation works.

sbt new akka/akka-grpc-quickstart-java.g8

Then continuing with the guide

./gradlew compileJava works as well.

but then ./gradlew --info runServer fails with the folling errors/issues:

Task ':runServer' is not up-to-date because:
Task has not declared any outputs.

and

Error: Main method not found in class com.example.helloworld.GreeterServer, please define the main method as:
   public static void main(String[] args)

ORIGINAL POST:

I am having trouble getting the Akka-GRPC example to run. I tried following this guide here but when I download the sample project it seems incomplete.

Thats the tree command output:

.
├── build.sbt
├── project
│   ├── build.properties
│   └── plugins.sbt
├── sbt
├── sbt.bat
└── sbt-dist
    ├── bin
    │   ├── sbt
    │   ├── sbt.bat
    │   ├── sbt-launch.jar
    │   └── sbt-launch-lib.bash
    └── conf
        ├── sbtconfig.txt
        └── sbtopts

4 directories, 11 files

There are no source files or gradlew oder pom.xml in the project structure.

Next I cloned the repository of that example from GitHub and followed the instructions in readme, mainly the command sbt new akka/akka-grpc-quickstart-java.g8.

$ sbt new akka/akka-grpc-quickstart-java.g8
[info] Loading settings for project akka-grpc-quickstart-java-g8-build from paradox.sbt,giter8.sbt ...
[info] Loading project definition from /home/johannes/IdeaProjects/akka-grpc-quickstart-java.g8/project
error: error while loading String, class file '/modules/java.base/java/lang/String.class' is broken
(class java.lang.NullPointerException/null)
[error] java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URI
...//had to remove stacktrace was too long for this post
[error]     at xsbt.boot.Boot.main(Boot.scala)
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? [error] java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URI
[error] Use 'last' for the full log.

then I went into the project/sources folder ./src/main/g8/ where the source files are located and tried to follow the instructions from the guide from in there. That also did not work because of some properties errors:

Before that I had to set another gradle version (6.1.1, was 4.5.1) in ./gradle/wrapper/gradle-wrapper.properties to make it compatible with Java 13.

$ ./gradlew compileJava

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'g8'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find gradle.plugin.com.lightbend.akka.grpc:akka-grpc-gradle-plugin:$akka_grpc_version$.
     Searched in the following locations:
       - file:/home/johannes/.m2/repository/gradle/plugin/com/lightbend/akka/grpc/akka-grpc-gradle-plugin/$akka_grpc_version$/akka-grpc-gradle-plugin-$akka_grpc_version$.pom
       - https://plugins.gradle.org/m2/gradle/plugin/com/lightbend/akka/grpc/akka-grpc-gradle-plugin/$akka_grpc_version$/akka-grpc-gradle-plugin-$akka_grpc_version$.pom
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s

Trying to at least temporarily get this to work i hardcoded the properties into the build.gradle file:

     //classpath 'gradle.plugin.com.lightbend.akka.grpc:akka-grpc-gradle-plugin:$akka_grpc_version$'
     classpath 'gradle.plugin.com.lightbend.akka.grpc:akka-grpc-gradle-plugin:0.7.3'

But that also only got me so far:

$ ./gradlew compileJava

FAILURE: Build failed with an exception.

* Where:
Build file '/home/johannes/IdeaProjects/akka-grpc-quickstart-java.g8/src/main/g8/build.gradle' line: 20

* What went wrong:
A problem occurred evaluating root project 'g8'.
> Failed to apply plugin [id 'com.google.protobuf']
   > Could not create an instance of type com.google.protobuf.gradle.ProtobufSourceDirectorySet.
      > 'void org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(java.lang.String, java.lang.String, org.gradle.api.internal.file.FileResolver, org.gradle.api.internal.file.collections.DirectoryFileTreeFactory)'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

Again could not include whole stacktrace because of character limit.

What am I missing? Which approach should I pursue further?

Oliver Tazl :

EDIT: Meanwhile, the pull request was accepted and the main repo (https://github.com/akka/akka-grpc-quickstart-java.g8) is up-to-date.

I downloaded the project using sbt new ..., but there was an error within the pom.xml (fixed version: https://github.com/olitazl/akka-grpc-quickstart-java.g8)

The problem of the example project are missing public modifier inside the GreeterServer class.

Therefore, you have to add public to the GreeterServer class and the method main within.

    public class GreeterServer ...
    public static void main(...)

If you recreate your project from my repo, the problem is fixed there as well.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Akka Java FSM by Example

Example of Akka EventBus for Java

grpc push notifcation example in java

GCP - Cloud Run with gRPC - Bookstore Example

Akka and Java 8 TestKit by Example

How do I properly generate the .pem file(s ?) needed for the grpc java auth example?

Example of integration Akka with existing java project

How correctly run evans (gRPC client)?

How to Secure A Cloud Run gRPC Service

How to properly install and run grpc with xampp and php

How example can be run in test?

How to run BlocObserver example in cli

How to run a daemon forever using Akka Actor?

How to configure play application with Akka to run in a cluster

How to unsubscribe Akka logs in run time

How to create Insecure Java grpc cilent for secure go grpc service

Is there an example of how to use akka-http with servlet container?

Cloud Run - gRPC authentication through service account - Java

Maven Java Fx example does not run - not duplicate

Why Akka waits in this example?

Akka messaging mechanisms by example

How do I successfully run JavaCV code example (JavaFxPlayVideoAndAudio.java)

How To Have Code Run For A Real Time Update For Condition Met Without The Need Of An Event(Button For Example) Java

How to swap in transport in java gRPC as alluded to in docs?

How to convert grpc java proto "timestamp" to date?

How to request gRPC server made by Go running on Cloud Run

gRPC, Go & Cloud Run - How to elegantly handle client authorisation?

How to run valgrind with basic c example?

How to run npm 'filestream' example code?