Linux下RMI调用出现的奇怪问题!!
FileServer是一个文件下载服务程序,供FileClient远程调用其Download(filename)方法。该程序在Windows下做服务器和客户机都完全没有问题。但是在Linux下一运行FileServer就返回如下出错信息.我郁闷的是为什么FileServer 程序在Windows下运行没有任何问题,到了Linux下就报错呢?
请各位高手相助,分数方面好说:)
端口采用默认的1099,如:rmiregistry 1099
其中policy.txt内容如下:
grant {
permission java.security.AllPermission "", "";
};
FileServer 返回的错误信息为:
[CHN@SAIBOG rmi]$ java -Djava.security.policy=policy.txt FileServer
FileServer: Error unmarshaling return header; nested exception is:
java.net.SocketException: Connection reset
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception
is:
java.net.SocketException: Connection reset
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
203)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:350)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at FileServer.main(FileServer.java:27)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java
:2150)
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream
.java:2163)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputS
tream.java:2634)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:734
)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253)
at sun.rmi.server.MarshalInputStream.<init>(MarshalInputStream.java:110)
at sun.rmi.transport.ConnectionInputStream.<init>(ConnectionInputStream.
java:38)
at sun.rmi.transport.StreamRemoteCall.getInputStream(StreamRemoteCall.ja
va:111)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
197)
... 4 more
[CHN@SAIBOG rmi]$
--------------
FileServer 源代码
import java.io.*;
import java.rmi.*;
public class FileServer {
public static void main(String argv[]) {
if(System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
FileInterface fi = new FileImpl("FileServer");
Naming.rebind("//127.0.0.1/FileServer", fi);//总是绑定
} catch(Exception e) {
System.out.println("FileServer: "+e.getMessage());
e.printStackTrace();
}
}
}