java远程调用(rmi)常见的两个错误

java的 rmi远程调用给分布式编程带来极大的方便,在使用rmi过程中若遇到以下两个问题,可以尝试如下的解决方法

问题1:java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:  java.lang.IllegalArgumentException: illegal remote method encountered:

解决方法 :若提示这样的错误说明接口函数未设置异常抛出,在所提示的函数后面加上throws RemoteException即可解决

问题2:exception: java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException :
解决方法:若提示这样的错误说明某个类是不能序列化的,需要在该类加上implements Serializable,即可解决

原文地址:https://www.cnblogs.com/cherish010/p/10843219.html