简体   繁体   English

如何避免Java RMI的MarshalException?

[英]How can I avoid the MarshalException for Java RMI?

I just finished a small program with java rmi and somehow it doesn't work. 我刚刚用Java rmi完成了一个小程序,但是某种程度上它不起作用。 Everytime I want to start the server I'm getting the MarshalException. 每次我想启动服务器时,都会收到MarshalException。 Are there any important points that I should be aware of them on how to implement the interface for the remote method invocation? 关于如何实现远程方法调用的接口,我有什么要注意的要点吗? I thought it would be possible to create an implementation but also include some additional methods like a constructor or private variables inside of the implementing class. 我认为可以创建一个实现,但还可以在实现类中包括一些其他方法,例如构造函数或私有变量。

Shouldn't this just work? 这不行吗?

Greetings 问候

In order to be able to transfer objects you need to make them implement Serializable . 为了能够传输对象,您需要使它们实现Serializable And perhaps have a default (no-arg) constructor (this is not a requirement for serialization though) 也许有一个默认的(无参数)构造函数(尽管这不是序列化的要求)

As helios noted, not only the class, but all your field hierarchy (classes of fields, and the classes of their fields) must be Serializable ) 正如helios所指出的,不仅是类,而且您的所有字段层次结构(字段的类及其字段的类)都必须是Serializable

Caused by: java.lang.ClassNotFoundException: vsys.ue04.server.RemoteChargeImplementation 引起原因:java.lang.ClassNotFoundException:vsys.ue04.server.RemoteChargeImplementation

There's your problem. 有你的问题。 That class is required at the client. 客户端需要该类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM