我们正在使用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创建问题
发布评论