我的小 akka 集群项目有一个奇怪的行为:我有一个非常简单的 application.conf:
akka {
# specifiy logger
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "DEBUG"
stdout-loglevel = "DEBUG"
# configure remote connection
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
remote {
enabled-transport = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "127.0.0.1"
port = 3100
}
}
cluster {
seed-nodes = [
"akka.tcp://mycluster@127.0.0.1:3100"
]
}
}
还有一个非常简单的主程序:
public class MediatorNodeStartup {
public static void main(String[] args) {
String port = System.getProperty("config.port") == null ? "3100" : System.getProperty("config.port");
Config config = ConfigFactory.parseString("akka.remote.netty.tcp.port=" + port)
.withFallback(ConfigFactory.load());
ActorSystem system = ActorSystem.create("mycluster", config);
}
}
Akka、Akka-Remote 和 Akka-Cluster 都通过 maven 包含并且在类路径中可见。现在,当我执行此操作时,它只是失败并出现 ClassNotFoundException: akka.cluster.ClusterActorRefProvider 尽管 akka.cluster.* 包肯定在我的类路径中。
奇怪的是,在另一台机器上,这段代码可以正常工作。所以我想这与我的 eclipse 或运行时配置有关......但遗憾的是我不知道从哪里开始搜索错误。有任何想法吗?如有必要,我将提供更多信息。