Akka ActorSystem创建问题

编程入门 行业动态 更新时间:2024-10-11 07:31:32
本文介绍了Akka ActorSystem创建问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们正在使用Akka 2.0 RC1,并在ActorSystem创建过程中获得异常消息,消息为: akka.actor.LocalActorRefProvider ,并且堆栈跟踪如下:

We are using Akka 2.0 RC1 and get an exception on ActorSystem creation with message: akka.actor.LocalActorRefProvider and stack trace as follows:

java.URLClassLoader$1.run(URLClassLoader.java:366) java.URLClassLoader$1.run(URLClassLoader.java:355) java.security.AccessController.doPrivileged(AccessController.java:279) java.security.AccessController.doPrivileged(AccessController.java:520) java.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在类路径中。

Any thoughts or ideas? We did confirm that LocalActorRefProvider was in classpath.

推荐答案

如果确实在问题中添加了实际的异常消息,那会有所帮助,但是我会在这里闲逛,并假设这是此错误消息,为在此线程中说明:

It would help if you did put the actual exception message in your question, but I will go on a limb here and assume this is this error message as illustrated in this thread:

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

运行正常当我以您描述的方式通过sbt在控制台下运行它时,对我也是如此。但是,如果我使用以下命令运行它:

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 -classpath

scala -classpath

并导入并执行,我确实得到了我提到的错误。

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

原因:

Akka使用创建 ActorSystem 的线程的上下文类加载器,并且由于每一行都是它自己的加载器,所以如果不使用它,就会遇到问题。

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.

建议:

每行 如果添加 -Yrepl-sync 选项,它应该可以正常工作

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

更多推荐

Akka ActorSystem创建问题

本文发布于:2023-11-25 09:30:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629224.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Akka   ActorSystem

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!