当前位置: 技术问答>java相关
一个rmi的小问题,在线等待,结决马上结帐?
来源: 互联网 发布时间:2015-10-15
本文导语: 我照例子做了个rmi. 所有类都编译通过了. 我把所有类都放在一个文件夹下,我想在本地机上运行所有程序. 当我动行服务器端程序时出现 RemoteException:java.rmi.ServerException: Server RemoteException; nested exception is: ...
我照例子做了个rmi.
所有类都编译通过了.
我把所有类都放在一个文件夹下,我想在本地机上运行所有程序.
当我动行服务器端程序时出现
RemoteException:java.rmi.ServerException: Server RemoteException; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: RemImpl_Stub
错误,而RemImpl_Stub类和服务器端的类都在一个目录下呀!为什么还会说找不到呀??
我还想知道在一台机器上运行rmi的详细过程和重要注意点和重要配制?
请各位高人找点!!
所有类都编译通过了.
我把所有类都放在一个文件夹下,我想在本地机上运行所有程序.
当我动行服务器端程序时出现
RemoteException:java.rmi.ServerException: Server RemoteException; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: RemImpl_Stub
错误,而RemImpl_Stub类和服务器端的类都在一个目录下呀!为什么还会说找不到呀??
我还想知道在一台机器上运行rmi的详细过程和重要注意点和重要配制?
请各位高人找点!!
|
这是我以前解答别人用的,再贴过来吧
我主要以Core Java V2 C5的例子为例,使用http的80端口方式传输,
其他方法,如ftp,classfileserver暂时没时间说了
1。 首先,保证你正在打开http服务,如果你是在用windows2000, 先到添加安装程序里添加
windows组件,安装IIS,然后点击资源管理器里的管理工具,点击service,保证IIS Admin Service已经打开了,
这是你就可以设定你的http服务了,点击资源管理器里的管理工具,点击Internet Service Manager,
右键单击默认http服务,点击属性,你会看到一些相关信息,比如端口号 80等,home directory那页,
保证read复选框被选定,最好把Directory Browsing也打开(调试方便)。
这些都做完了,你在C:Inetpubwwwroot里建一个目录download,把Product.class,ProductImpl_Stub.class
拷进去,这时你可以测试一下,http服务是否可以下载你的stub,
你打开一个IE浏览器,输入http://localhost:80/download, (如果刚才你没改80,那么http://localhost/download这样也可以)
这时,如果刚才你打开了Directory Browsing,你就可以看到类似这样的东西
localhost - /download/
--------------------------------------------------------------------------------
[To Parent Directory] Saturday, September 14, 2002 9:08 PM 219 Product.class Saturday, September 14, 2002 9:09 PM 2876 ProductImpl_Stub.class
--------------------------------------------------------------------------------
点击ProductImpl_Stub.class,会谈出一个对话框让你下载,http80这就搞定了!这表示你的web服务可以
让你写的rmi程序的客户端下载stub了。
2。 把服务端需要的类放到一个server目录里,这个目录不用放到wwwroot里,放到你任何的地方,比如d:server,
以Core Java的第5章为例,你要放入这些文件:
Product.class
ProductServer.class
ProductImpl.class
ProductImpl_Stub.class
3。 随便找个地方建一个client目录,如d:client,把客户端程序放进去
Product.class
ProdcutClient.class
client.policy
其中client.policy要保证允许客户端访问http服务,默认情况下,http用80断口,所以,你的client.policy一般可以这样写
grant
{ permission java.net.SocketPermission
"*:1024-65535", "connect,accept";
permission java.net.SocketPermission
"*:80", "connect,accept";
};
4。 然后开一个dos窗口,键入set classpath=回车,这时你的CLASSPATH被清空,防止混乱
例如
C:>set classpath=
C:>set classpath
Environment variable classpath not defined
C:>rmiregistry
5。 然后再server目录里启动服务端:
E:Server>java -Djava.rmi.server.codebase=http://localhost/download/ ProductServer
Constructing server implementations...
Binding server implementations to registry...
Waiting for invocations from clients...
6。 然后再client目录里启动客户端
E:Client>java -Djava.security.policy=client.policy ProductClient
I am a Blackwell Toaster. Buy me!
I am a ZapXpress Microwave Oven. Buy me!
结束
我主要以Core Java V2 C5的例子为例,使用http的80端口方式传输,
其他方法,如ftp,classfileserver暂时没时间说了
1。 首先,保证你正在打开http服务,如果你是在用windows2000, 先到添加安装程序里添加
windows组件,安装IIS,然后点击资源管理器里的管理工具,点击service,保证IIS Admin Service已经打开了,
这是你就可以设定你的http服务了,点击资源管理器里的管理工具,点击Internet Service Manager,
右键单击默认http服务,点击属性,你会看到一些相关信息,比如端口号 80等,home directory那页,
保证read复选框被选定,最好把Directory Browsing也打开(调试方便)。
这些都做完了,你在C:Inetpubwwwroot里建一个目录download,把Product.class,ProductImpl_Stub.class
拷进去,这时你可以测试一下,http服务是否可以下载你的stub,
你打开一个IE浏览器,输入http://localhost:80/download, (如果刚才你没改80,那么http://localhost/download这样也可以)
这时,如果刚才你打开了Directory Browsing,你就可以看到类似这样的东西
localhost - /download/
--------------------------------------------------------------------------------
[To Parent Directory] Saturday, September 14, 2002 9:08 PM 219 Product.class Saturday, September 14, 2002 9:09 PM 2876 ProductImpl_Stub.class
--------------------------------------------------------------------------------
点击ProductImpl_Stub.class,会谈出一个对话框让你下载,http80这就搞定了!这表示你的web服务可以
让你写的rmi程序的客户端下载stub了。
2。 把服务端需要的类放到一个server目录里,这个目录不用放到wwwroot里,放到你任何的地方,比如d:server,
以Core Java的第5章为例,你要放入这些文件:
Product.class
ProductServer.class
ProductImpl.class
ProductImpl_Stub.class
3。 随便找个地方建一个client目录,如d:client,把客户端程序放进去
Product.class
ProdcutClient.class
client.policy
其中client.policy要保证允许客户端访问http服务,默认情况下,http用80断口,所以,你的client.policy一般可以这样写
grant
{ permission java.net.SocketPermission
"*:1024-65535", "connect,accept";
permission java.net.SocketPermission
"*:80", "connect,accept";
};
4。 然后开一个dos窗口,键入set classpath=回车,这时你的CLASSPATH被清空,防止混乱
例如
C:>set classpath=
C:>set classpath
Environment variable classpath not defined
C:>rmiregistry
5。 然后再server目录里启动服务端:
E:Server>java -Djava.rmi.server.codebase=http://localhost/download/ ProductServer
Constructing server implementations...
Binding server implementations to registry...
Waiting for invocations from clients...
6。 然后再client目录里启动客户端
E:Client>java -Djava.security.policy=client.policy ProductClient
I am a Blackwell Toaster. Buy me!
I am a ZapXpress Microwave Oven. Buy me!
结束
|
0)set classpath
1) start rmiregistry
2) start the server program
3) start the client program
至于什么http嘛,以后有空再说吧,不要一口吃饱呀,他才开始学呀
1) start rmiregistry
2) start the server program
3) start the client program
至于什么http嘛,以后有空再说吧,不要一口吃饱呀,他才开始学呀
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。