在JDK 的RMI中我有个方法需要传参数,参数为InputStream,在远程调用的的时候报错,
这是我客户端代码
[code="java"]
try {
ICheckServer rmi = (ICheckServer) Naming.lookup("rmi://127.0.0.1:2012/checkserver");
InputStream in = new Thread().getContextClassLoader().getResourceAsStream("jolt-config.xml");
rmi.initTuxedoConnect(in);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
[/code]
错误信息:
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: java.io.BufferedInputStream
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:138)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy0.initTuxedoConnect(Unknown Source)
at test.Test.main(Test.java:18)
Caused by: java.io.NotSerializableException: java.io.BufferedInputStream
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)