gpt4 book ai didi

java - 类 akka.actor.TypedActor$MethodCall 无法使用修饰符 "public abstract"访问类 JobManager 的成员

转载 作者:太空宇宙 更新时间:2023-11-04 13:38:35 25 4
gpt4 key购买 nike

我在 Java 中使用 Akka 类型的 actor。我有一个 BatchManager ,它是与 Controller 的接口(interface),还有一个 JobManager ,它创建一些工作人员并执行作业。 JobManager 看起来像

interface JobManager {
public Future<String> execute();
public Future<AwaitableBatchStatusResponse> awaitCompletion();
public Future<BatchStatusResponse> getStatus();
public Future<String> reloadFailures();
public void jobComplete(JobMessage message);
}

其中Futurescala.concurrent.Future。实现类重写了所有这些方法,特别是

class JobManagerImpl implements JobManager {
public JobManagerImpl() {
System.out.println("JobManagerImpl constructor start");
// do some stuff
System.out.println("JobMangerImpl constructor end");
}

@Override
public Future<String> execute() {
System.out.println("start execute on jobmanager");
// do some stuff
System.out.println("end execute in jobmanager");
return Futures.successful("blah");
}
}

JobManager 已成功构造(只要我在构造函数末尾打印出“JobMangerImpl constructor end”)。但是,BatchManager 然后在新的 JobManager 上调用执行,并且我被告知该消息将成为死信(以及线程标题中的错误 - 下面是堆栈跟踪)。我的 JobManagerImpl#execute 中的 println 没有运行。

Enqueue job: d90c4d58-3142-48cd-8f3e-96e75d4ca7d1
Execute job: d90c4d58-3142-48cd-8f3e-96e75d4ca7d1
start create job manager in poll
JobManagerImpl constructor start : d90c4d58-3142-48cd-8f3e-96e75d4ca7d1
JobMangerImpl constructor end
end create jobManager in poll
begin execute in batchmanager
end execute in batchmanager
JobManagerImpl constructor start : d90c4d58-3142-48cd-8f3e-96e75d4ca7d1
JobMangerImpl constructor end
[INFO] [07/15/2015 15:36:07.088] [PerformanceAsync-akka.actor.default-dispatcher-10] [akka://PerformanceAsync/deadLetters] Message [java.lang.String] from Actor[akka://PerformanceAsync/user/StandardJobManager#1902186473] to Actor[akka://PerformanceAsync/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[ERROR] [07/15/2015 15:36:07.089] [PerformanceAsync-akka.actor.default-dispatcher-8] [akka://PerformanceAsync/user/StandardJobManager/StandardJobManager:d90c4d58-3142-48cd-8f3e-96e75d4ca7d1:JobManager] Class akka.actor.TypedActor$MethodCall can not access a member of class com.async.JobManager with modifiers "public abstract"
java.lang.IllegalAccessException: Class akka.actor.TypedActor$MethodCall can not access a member of class com.async.JobManager with modifiers "public abstract"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:101)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:295)
at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:287)
at java.lang.reflect.Method.invoke(Method.java:476)
at akka.actor.TypedActor$MethodCall.apply(TypedActor.scala:145)
at akka.actor.TypedActor$TypedActor$$anonfun$receive$1$$anonfun$applyOrElse$2.apply(TypedActor.scala:311)
at akka.actor.TypedActor$TypedActor.withContext(TypedActor.scala:299)
at akka.actor.TypedActor$TypedActor$$anonfun$receive$1.applyOrElse(TypedActor.scala:306)
at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
at akka.actor.TypedActor$TypedActor.aroundReceive(TypedActor.scala:246)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

我很困惑 - 我已经用公共(public)方法重写了所有 JobManager 方法,那么为什么 Akka 无法访问它们?

最佳答案

问题似乎是我在 BatchManagerImpl 的静态内部类中创建了 JobManagerImpl - 这个内部类处于一种奇怪的边缘状态,其中 TypedActor.get(TypedActor.context()) 没有抛出在 TypedActor 上下文之外使用的异常,但以这种方式实例化的任何内容都在内部被破坏。

关于java - 类 akka.actor.TypedActor$MethodCall 无法使用修饰符 "public abstract"访问类 JobManager 的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31441811/

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