gpt4 book ai didi

java - Akka ActorSystem 创建问题

转载 作者:行者123 更新时间:2023-11-30 07:28:05 24 4
gpt4 key购买 nike

我们使用的是 Akka 2.0 RC1,在创建 ActorSystem 时出现异常,消息为:akka.actor.LocalActorRefProvider,堆栈跟踪如下:

java.net.URLClassLoader$1.run(URLClassLoader.java:366)
java.net.URLClassLoader$1.run(URLClassLoader.java:355)
java.security.AccessController.doPrivileged(AccessController.java:279)
java.security.AccessController.doPrivileged(AccessController.java:520)
java.net.URLClassLoader.findClass(URLClassLoader.java:354)
java.lang.ClassLoader.loadClass(ClassLoader.java:450)
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
java.lang.ClassLoader.loadClass(ClassLoader.java:385)
akka.actor.ReflectiveDynamicAccess.getClassFor(DynamicAccess.scala:94)
akka.actor.ReflectiveDynamicAccess.createInstanceFor(DynamicAccess.scala:102)
akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:439)
akka.actor.ActorSystem$.apply(ActorSystem.scala:41)
akka.actor.ActorSystem$.apply(ActorSystem.scala:51)
kozo.excel.impl.ConnectClient.<init>(ConnectClient.scala:26)

异常发生在这一行:

system = ActorSystem("FunctionClient")

有什么想法或想法吗?我们确实确认 LocalActorRefProvider 在类路径中。

最佳答案

如果您确实将实际的异常消息放入您的问题中,那将会有所帮助,但我会在这里继续并假设这是此错误消息 illustrated in this thread :

java.lang.ClassCastException: interface akka.actor.ActorRefProvider is
not assignable from class akka.actor.LocalActorRefProvider

It runs fine for me too when I run it under the console through sbt the way you describe. However, if I run it using:

scala -类路径

and import and execute, I do get the error I mentioned.

原因:

Akka uses the context class loader from the thread that created the ActorSystem, and since every line is on it's own loader, you'll have a problem if you don't use that.

建议:

Each line in the repl runs in a separate thread.
If you add the -Yrepl-sync option it should work fine

关于java - Akka ActorSystem 创建问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9318340/

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