Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find symbol symbol: class Greet #32337

Closed
shaoshuaidu opened this issue Mar 2, 2024 · 8 comments
Closed

cannot find symbol symbol: class Greet #32337

shaoshuaidu opened this issue Mar 2, 2024 · 8 comments

Comments

@shaoshuaidu
Copy link

Hi, everyone! I am new to java and akka, I try to run akka-quickstart-java demo but this error keeps happen. Mybe this problem happens due to the java version. But I work on a supercomputer cluster so I am not able to update the java8 to 11 or 17.
Anyone can help me with this problem? thank you in advance.

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[10,54] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterBot.java:[6,57] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterBot.java:[8,35] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterBot.java:[15,44] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterBot.java:[21,27] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterBot.java:[25,56] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterBot.java:[25,29] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[12,52] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[12,17] cannot find symbol
symbol: class record
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[13,54] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[13,17] cannot find symbol
symbol: class record
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[15,26] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[19,32] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[24,18] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[28,35] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[28,20] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterMain.java:[17,35] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterBot.java:[22,53] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterBot.java:[31,44] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[25,42] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/Greeter.java:[31,32] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterMain.java:[37,25] cannot find symbol
symbol: class Greeted
location: class $package$.Greeter
[ERROR] /home/sdu/dss_git/akka-quickstart-java.g8/src/main/g8/src/main/java/$package$/GreeterMain.java:[39,33] cannot find symbol
symbol: class Greet
location: class $package$.Greeter
[INFO] 23 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

@johanandren
Copy link
Member

If you must stay on JDK 8 the last version of Akka supporting it is 2.8.5, you could try building the quickstart with that.

@shaoshuaidu
Copy link
Author

If you must stay on JDK 8 the last version of Akka supporting it is 2.8.5, you could try building the quickstart with that.

Hi Johanadren, thank you for your reply. Actually I am using Akka 2.8.5. Here is my pom file. Is there anyproblem with it?

4.0.0
<groupId>hello-akka-java</groupId>
<artifactId>app</artifactId>
<version>1.0</version>

<properties>
  <akka.version>2.8.5</akka.version>
</properties>

<repositories>
    <repository>
        <id>akka-repository</id>
        <name>Akka library repository</name>
        <url>https://repo.akka.io/maven</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-actor-typed_2.13</artifactId>
        <version>${akka.version}</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.13</version>
    </dependency>
    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-actor-testkit-typed_2.13</artifactId>
        <version>${akka.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>    
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <executable>java</executable>
                <arguments>
                    <argument>-classpath</argument>
                    <classpath />
                    <argument>$package$.AkkaQuickstart</argument>
                </arguments>
            </configuration>
        </plugin>
    </plugins>
</build>

@shaoshuaidu
Copy link
Author

If you must stay on JDK 8 the last version of Akka supporting it is 2.8.5, you could try building the quickstart with that.

And my java version is 1.8 and maven version is 3.8.3. Should the version of maven be same as the version of maven compiler plugin?

@johanandren
Copy link
Member

Ah, I see now what is wrong, you have probably cloned the entire java quickstart repository, but that is structured for project creation through the sbt (the build tool most common for Scala) templating functionality, not to be cloned and run directly.

Generally such project creation is done via sbt new akka/akka-quickstart-scala.g8, which will give you some prompts to specify project name, package name, Akka version etc.

If you do not want to install sbt to do that you can instead download a zip file of the project template from this page: https://developer.lightbend.com/guides/akka-quickstart-java/ and it should work as expected.

@shaoshuaidu
Copy link
Author

shaoshuaidu commented Mar 4, 2024

Ah, I see now what is wrong, you have probably cloned the entire java quickstart repository, but that is structured for project creation through the sbt (the build tool most common for Scala) templating functionality, not to be cloned and run directly.

Generally such project creation is done via sbt new akka/akka-quickstart-scala.g8, which will give you some prompts to specify project name, package name, Akka version etc.

If you do not want to install sbt to do that you can instead download a zip file of the project template from this page: https://developer.lightbend.com/guides/akka-quickstart-java/ and it should work as expected.

Hi Johanandren,

Thank you for the information. Scala is an interesting and new language for me. But it seems not to be the reason of problem.

I finally found the bug is cuased by java version incompatibility. The code below (which is a record class, only supported by java 14 version and afterwards), is not supported by java 8.

public static record Greet(String whom, ActorRef<Greeted> replyTo) {}
 public static record Greeted(String whom, ActorRef<Greet> from) {}

So I change these code into typical class, and it works. Cheers!

public static final class Greet{
    private final String whom;
    private final ActorRef<Greeted> replyTo;

    public Greet(String whom, ActorRef<Greeted> replyTo){
      this.whom = whom;
      this.replyTo = replyTo;
    }

    public String whom(){
      return this.whom;
    }

    public ActorRef<Greeted> replyTo(){
      return this.replyTo;
    }

    public String toString(){
      return String.format("Point[x=%s, y=%s]", this.whom, this.replyTo);
    }

    public boolean equals(Object o){
      return true;
    }

    public int hashCode(){
      return 110;
    }
}
 public static final class Greeted{
    private final String whom;
    private final ActorRef<Greet> from;

    public Greeted(String whom, ActorRef<Greet> from){
      this.whom = whom;
      this.from = from;
    }

    public String whom(){
      return this.whom;
    }

    public ActorRef<Greet> from(){
      return this.from;
    }

    public String toString(){
      return String.format("Point[x=%s, y=%s]", this.whom, this.from);
    }

    public boolean equals(Object o){
      return false;
    }

    public int hashCode(){
      return 120;
    }
  }

@johanandren
Copy link
Member

Ah, sorry, didn't remember that, yes, we switched to showcasing newer JDK features a while ago, if you start from commit akka/akka-quickstart-java.g8@269d369 I think that should still work with JDK 8 (alternatively rewrite those records to regular Java classes like you did)

@shaoshuaidu
Copy link
Author

Ah, sorry, didn't remember that, yes, we switched to showcasing newer JDK features a while ago, if you start from commit akka/akka-quickstart-java.g8@269d369 I think that should still work with JDK 8 (alternatively rewrite those records to regular Java classes like you did)

Yeah, thanks. And I also create a new repo for java8 version, for new beginners like me. Here is the link https://github.com/shaoshuaidu/akka-quickstart-java8.

@johanandren
Copy link
Member

Thanks for sharing, I'll close this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants