Linux下RMI调用出现的奇怪问题!!

at89c51 2003-08-21 03:20:38
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();
}
}
}
...全文
178 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
at89c51 2003-08-22
  • 打赏
  • 举报
回复
我从forum.java.sun.com论坛上新查到了一些资料,发现也有人曾遇到过同样的问题,感觉上跟J2DK1.4.1_01和RedHat 8之间有关??

http://forum.java.sun.com/thread.jsp?thread=384833&forum=58&message=1658015
at89c51 2003-08-22
  • 打赏
  • 举报
回复
谢谢 javaVegetable(风) 的关注:)

-----------------------------------
1.我用Linux下用rmic生成stub和Skel的时候就已经报错了,不知道会是什么原因导致呢?以下是输出信息:

[CHN@SAIBOG rmi]$ rmic FileImpl
java.lang.Exception: compiler exited with status: 1
at 0x4027815f: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/libg
cj.so.3)
at 0x4026b0d2: java.lang.Exception.Exception(java.lang.String) (/usr/lib/libg
cj.so.3)
at 0x4032b9e6: gnu.java.rmi.rmic.CompilerProcess.compile(java.lang.String) (/
usr/lib/libgcj.so.3)
at 0x403308c2: gnu.java.rmi.rmic.RMIC.compile(java.lang.String) (/usr/lib/lib
gcj.so.3)
at 0x4032becd: gnu.java.rmi.rmic.RMIC.processClass(java.lang.String) (/usr/li
b/libgcj.so.3)
at 0x4032bc7c: gnu.java.rmi.rmic.RMIC.run() (/usr/lib/libgcj.so.3)
at 0x4032bb3b: gnu.java.rmi.rmic.RMIC.main(java.lang.String[]) (/usr/lib/libg
cj.so.3)
at 0x40252308: gnu.gcj.runtime.FirstThread.call_main() (/usr/lib/libgcj.so.3)
at 0x402bd0b1: gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.3)
at 0x4025efdc: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.3)
at 0x4022b78c: _Jv_RunMain(java.lang.Class, byte const, int, byte const, bool
ean) (/usr/lib/libgcj.so.3)
at 0x4022b8ad: JvRunMain (/usr/lib/libgcj.so.3)
at 0x080485a0: ?? (??:0)
at 0x420158d4: ?? (??:0)
at 0x080484ed: ?? (??:0)
[CHN@SAIBOG rmi]$

--------------------------------------
2. 我想请问:UnmarshalException 是一个什么样的异常呢?从字面上都没弄明白。以下是JDK_DOC里面查到的相关信息。

public class UnmarshalException
extends RemoteException
An UnmarshalException can be thrown while unmarshalling the parameters or results of a remote method call if any of the following conditions occur:

if an exception occurs while unmarshalling the call header
if the protocol for the return value is invalid
if a java.io.IOException occurs unmarshalling parameters (on the server side) or the return value (on the client side).
if a java.lang.ClassNotFoundException occurs during unmarshalling parameters or return values
if no skeleton can be loaded on the server-side; note that skeletons are required in the 1.1 stub protocol, but not in the 1.2 stub protocol.
if the method hash is invalid (i.e., missing method).
if there is a failure to create a remote reference object for a remote object's stub when it is unmarshalled.

------------------------------------

3. Linux下确实配置了iptables,但估计问题不是这里吧?我在Linux下用Socket 创建监听端口没有问题啊,当然了普通用户只能创建1024以上的端口。

4. 你的Java的IO出了问题,可不可以再详细一些呢?Linux的其它什么配置会有可能造成这种问题呢?

谢谢!!

javaVegetable 2003-08-21
  • 打赏
  • 举报
回复
从问题来看很复杂,所以关注。
不过我想问是不是你的java的io中出了问题。
你看一下是不是你的linux的配置中将你的端口封住了所以没有办法建立连接。
我想可能是linux配置中的问题吧

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧