gpt4 book ai didi

java - RMI 异常 "error marshalling arguments"

转载 作者:搜寻专家 更新时间:2023-11-01 02:06:11 25 4
gpt4 key购买 nike

我正在开发一个 RMI 项目,该项目有两个独立的客户端和服务器项目。我使用了启动rmiregistry。当我尝试运行我的服务器应用程序时,出现异常。

public class Runner extends UnicastRemoteObject {

public Runner() throws RemoteException {
try {
ServerOperations so = new ServerSide();
Naming.rebind("rmi://localhost:2000/MiveCoffeeService", so);
System.out.println("Server is online.");

} catch (RemoteException | MalformedURLException | FileNotFoundException ex) {
Logger.getLogger(Runner.class.getName()).log(Level.SEVERE, null, ex);
}
}

public static void main(String[] args) throws RemoteException {
new Runner();
}

}

异常(exception)情况是:

Sep 11, 2015 9:05:51 PM ir.nscogroup.coffeemive.Runner <init>
SEVERE: null
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: dataaccess.ServerSide
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:177)
at ir.nscogroup.coffeemive.Runner.<init>(Runner.java:29)
at ir.nscogroup.coffeemive.Runner.main(Runner.java:38)
Caused by: java.io.NotSerializableException: dataaccess.ServerSide
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
... 4 more

怎么了?

最佳答案

异常堆栈跟踪告诉您确切哪里出了问题:

java.io.NotSerializableException: dataaccess.ServerSide

您正在尝试序列化不可序列化的类 dataaccess.ServerSide。解决方案:让您的类和所有必要的组成类实现 Serializable 接口(interface)。

关于java - RMI 异常 "error marshalling arguments",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32528473/

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