RMI服务器启动绑定问题

发布于 2024-11-18 22:43:59 字数 341 浏览 2 评论 0原文

当我尝试绑定接口实现时遇到问题。

java.rmi.MarshalException: error marshalling arguments; nested exception is: 
    java.io.NotSerializableException: java.util.concurrent.ThreadPoolExecutor

有谁知道为什么会发生这种情况? 为什么 ThreadPoolExecutor 应该是可序列化的?它既不包含在我的代码库 jar 文件中,也不包含在策略文件指定的文件中。 这两个参数都只包含两个类文件。这些反过来又导入更复杂的类。这是我的问题的可能原因吗?

I have a problem when I try to bind my interface implementation.

java.rmi.MarshalException: error marshalling arguments; nested exception is: 
    java.io.NotSerializableException: java.util.concurrent.ThreadPoolExecutor

Has anyone an idea why this happens?
Why should ThreadPoolExecutor be serializable anyway? It is neither included in my jar file that is my code base, nor is it in the file that is specified by the policy file.
Both parameters only include two class file. These in turn import more complex classes. Is this a possible reason for my problems?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

染年凉城似染瑾 2024-11-25 22:43:59

您尚未导出远程对象。它不扩展 UnicastRemoteObject,并且您还没有调用 UnicastRemoteObject.exportObject()。其中任何一个都可以(不是两个),而你还没有完成其中任何一个。因此,您的实际远程对象在 bind() 方法中序列化到注册表,但失败是因为您的远程对象具有 ThreadPoolExecutor 类型的非瞬态实例成员,该成员不可序列化。但问题在于导出,而不是实例成员。如果导出对象,其存根将被序列化到注册表,并且不会出现问题。

You haven't exported your remote object. It doesn't extend UnicastRemoteObject, and you haven't called UnicastRemoteObject.exportObject(). Either of those would do it (not both), and you haven't done either of them. So your actual remote object was serialized to the Registry in the bind() method, and this failed because your remote object has a non-transient instance member of type ThreadPoolExecutor, which isn't serializable. But the problem is the exporting, not the instance member. If the object was exported, its stub would be serialized to the Registry and the issue wouldn't arise.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文