AKKA 원격 시스템으로 2 프레임 워크 연결
-
11-12-2019 - |
문제
원격 AKKA 시스템을 재생 프레임 워크에 연결하려고하면 구성에 문제가있는 것처럼 보입니다.
플레이 프레임 워크 컨트롤러 클래스와 아래의 로컬 오브젝트가 코드가 다음과 같습니다.
실행할 때 다음 메시지가 웹 페이지에 표시됩니다
[ClassNotFoundException: akka.remote.RemoteActorRefProvider]
In C:\Users\FAISAL\workspace\Rakka\app\controllers\Application.java at line 21.
17 public static Result index() throws InterruptedException {
18
19 System.out.println(" Local Node Called0");
20
21 ActorSystem csystem = ActorSystem.create("Application", ConfigFactory.load().getConfig("LocalNode"));
22 ActorRef localNode = csystem.actorOf(new Props(LocalNode.class));
23
24 System.out.println(" Local Node Called1");
25 localNode.tell("Hello");
.
이것은 컨트롤러입니다.
public class Application extends Controller {
public static Result index() throws InterruptedException {
System.out.println(" Local Node Called0");
ActorSystem csystem = ActorSystem.create("Application", ConfigFactory.load().getConfig("LocalNode"));
ActorRef localNode = csystem.actorOf(new Props(LocalNode.class));
System.out.println(" Local Node Called1");
localNode.tell("Hello World");
System.out.println(" Local Node Called2");
Thread.sleep(5000);
csystem.shutdown();
return ok(index.render("I am OK"));
}
}
.
이것은 현지 akka 배우 입니다
public class LocalNode extends UntypedActor {
LoggingAdapter log = Logging.getLogger(getContext().system(), this);
Timeout timeout = new Timeout(Duration.parse("5 seconds"));
ActorRef master;
public void preStart()
{
/* Get reference to Master Node*/
master = getContext().actorFor("akka://MasterNode@127.0.0.1:2552/user/master");
}
@Override
public void onReceive(Object message) throws Exception {
System.out.println(" Future called ");
Future<Object> future = Patterns.ask(master , message.toString(), timeout);
String result = (String) Await.result(future, timeout.duration());
log.info("Messagefrom Server", result);
}
}
.
이것은 로컬 플레이 Conf 파일 입니다.
#confige the remote connection
LocalNode {
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
transport = "akka.remote.netty.NettyRemoteTransport"
netty {
hostname = "127.0.0.1"
port = 0
}
}
}
}
.
아래 코드는 원격 AKKA 시스템에서입니다.
이것은 원격 마스터 입니다.
public class MasterNode implements Bootable
{
final ActorSystem system;
public MasterNode() {
system = ActorSystem.create("MasterNode", ConfigFactory.load()
.getConfig("master"));
ActorRef actor = system.actorOf(new Props(MasterActor.class),"master");
System.out.println(" Master Node is called ");
}
public void startup() {
}
public void shutdown() {
system.shutdown();
}
}
.
이것은 원격 AKKA 배우 시스템 입니다.
public class MasterActor extends UntypedActor {
@Override
public void onReceive(Object message) throws Exception {
if (message instanceof String) {
// Get reference to the message sender and reply back
getSender().tell(message + " got something");
}
}
}
.
이것은 원격 AKKA Config 에서입니다.
master {
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
transport = "akka.remote.netty.NettyRemoteTransport"
netty {
hostname = "127.0.0.1"
port = 2552
}
}
}}
.
시스템을 실행하려면 먼저 AKKA 원격 시스템을 시작한 다음 재생 2 프레임 워크를 시작하십시오
재생 프레임 록을 실행 한 후 다음과 같은 오류가 발생합니다
[info] play - Application started (Dev)
Local Node Called0
[error] application -
! @6bol84j48 - Internal server error, for request [GET /] ->
play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[ClassN
otFoundException: akka.remote.RemoteActorRefProvider]]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [
play_2.9.1.jar:2.0.2]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [
play_2.9.1.jar:2.0.2]
at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2]
at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.
2]
at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.
2]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.j
ar:2.0.2]
Caused by: java.lang.ClassNotFoundException: akka.remote.RemoteActorRefProvider
at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.7.0_01]
at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.7.0_01]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0
_01]
at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.7.0_01]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.7.0_01]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.7.0_01]
.
는 제안이나 도움을받을 수있는 것처럼 보이지 않습니다.
해결책
플레이 2 응용 프로그램에서 AKKA REMOTE에 종속성을 추가하는 것을 잊어 버렸을 것입니다.
재생 2.0.3을 사용하는 경우 project/Build.scala
파일에 다음 종속성을 추가하십시오.
val appDependencies = Seq(
"com.typesafe.akka" % "akka-remote" % "2.0.2"
)
. 제휴하지 않습니다 StackOverflow