Akka ActorSystem创建问题 [英] Akka ActorSystem creation issue

查看:372
本文介绍了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.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在类路径中。

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创建问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆