gpt4 book ai didi

java.lang.NoClassDefFoundError : scala/Predef$any2stringadd$ 错误

转载 作者:行者123 更新时间:2023-11-30 06:11:17 25 4
gpt4 key购买 nike

我正在使用 Akka Distributed Publish Subscribe with Java,关注 this examples来自文档

但是每当我运行我的代码时,我都会得到一个java.lang.NoClassDefFoundError: scala/Predef$any2stringadd$

它似乎无法归档 scala 库,但我可以在依赖项选项卡上看到 scala 库。我还为两个 Akka 依赖项使用了相同的版本。

我对 pom.xml 的依赖:

<dependencies>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[4.0,)</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-stream</artifactId>
<version>[4.0,)</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>0.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-kafka</artifactId>
<version>0.10.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-cluster-tools_2.11</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>

IntelliJ 显示:

enter image description here

这是导致异常的代码:

ActorSystem actorSystem = ActorSystemManager.INSTANCE.getActorSystem();
ActorRef actorSubscriber = actorSystem.actorOf(Props.create(TwitterSubscriber.class));

其中 ActorSystemManager 是传递给 actor 系统的单例。

public enum ActorSystemManager {
INSTANCE;

private final ActorSystem actorSystem;

private ActorSystemManager() {
actorSystem = ActorSystem.create("localized_tweets");
}

public ActorSystem getActorSystem() {
return actorSystem;
}
}

这是完整的堆栈跟踪:

Connected to the target VM, address: '127.0.0.1:51608', transport: 'socket'
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$any2stringadd$
at akka.actor.RootActorPath.<init>(ActorPath.scala:273)
at akka.event.Logging$StandardOutLogger.<init>(Logging.scala:800)
at akka.event.Logging$.<init>(Logging.scala:821)
at akka.event.Logging$.<clinit>(Logging.scala)
at akka.event.LoggingBus$class.setUpStdoutLogger(Logging.scala:74)
at akka.event.LoggingBus$class.startStdoutLogger(Logging.scala:90)
at akka.event.EventStream.startStdoutLogger(EventStream.scala:28)
at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:613)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:143)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:110)
at akka.actor.ActorSystem$.create(ActorSystem.scala:58)
at akka.actor.ActorSystem.create(ActorSystem.scala)
at com.dazito.twitter.akka.ActorSystemManager.<init>(ActorSystemManager.java:16)
at com.dazito.twitter.akka.ActorSystemManager.<clinit>(ActorSystemManager.java:11)
at com.dazito.twitter.Main.main(Main.java:36)
Caused by: java.lang.ClassNotFoundException: scala.Predef$any2stringadd$
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 15 more
Disconnected from the target VM, address: '127.0.0.1:51608', transport: 'socket'

关于如何解决此异常的任何帮助?

最佳答案

将您的 Scala 库更新到 2.11 版本。

关于java.lang.NoClassDefFoundError : scala/Predef$any2stringadd$ 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34345869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com