RMI服务器启动绑定问题
当我尝试绑定接口实现时遇到问题。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尚未导出远程对象。它不扩展 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.