RMI 找不到绑定对象?
我有以下 RMI 服务器:
public static void main(String[] args) {
try{
ChatSystemImpl chatSystem = new ChatSystemImpl();
ChatSystem chatSystem_stub = (ChatSystem) UnicastRemoteObject.exportObject(chatSystem, 6001);
Registry registry = LocateRegistry.getRegistry("localhost", 6001);
registry.bind("ChatSystem1", chatSystem_stub);
System.out.println("Server up.");
}
catch(Exception ex){
ex.printStackTrace();
}
}
当我运行它时,我得到:
ava.rmi.NoSuchObjectException: no such object in table
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at fr.inp.ensimag.examples.chatsystem.Main.main(Main.java:30)
好吧,我不知道出了什么问题......现在盯着它超过 2 个小时。
这是接口(如果需要):
public interface ChatSystem extends Remote{
void registerUser(UserInfo newUser) throws RemoteException;
void unregisterUser(UserInfo user) throws RemoteException;
boolean userExists(UserInfo user) throws RemoteException;
void send(MessageInfo message) throws RemoteException;
}
实现具有以下标头,主体仅包含未真正实现的方法,它们只是显示 UnsupportedOperationException
:
public class ChatSystemImpl implements ChatSystem
ChatSystem
接口位于其他项目,然后是其余的源代码(如果有任何重要性的话)。
谢谢。
I have the folloving RMI server:
public static void main(String[] args) {
try{
ChatSystemImpl chatSystem = new ChatSystemImpl();
ChatSystem chatSystem_stub = (ChatSystem) UnicastRemoteObject.exportObject(chatSystem, 6001);
Registry registry = LocateRegistry.getRegistry("localhost", 6001);
registry.bind("ChatSystem1", chatSystem_stub);
System.out.println("Server up.");
}
catch(Exception ex){
ex.printStackTrace();
}
}
When I run it I get:
ava.rmi.NoSuchObjectException: no such object in table
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at fr.inp.ensimag.examples.chatsystem.Main.main(Main.java:30)
Well I have no idea whats wrong... Staring on it for more then 2 hours right now.
This is the interface (if needed):
public interface ChatSystem extends Remote{
void registerUser(UserInfo newUser) throws RemoteException;
void unregisterUser(UserInfo user) throws RemoteException;
boolean userExists(UserInfo user) throws RemoteException;
void send(MessageInfo message) throws RemoteException;
}
The implementation has following header, the body just contains methods that are not really implemented, they just thow UnsupportedOperationException
:
public class ChatSystemImpl implements ChatSystem
The ChatSystem
interface is in other project then the rest of source code if it is of any importance.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的注册表尚未导出。这通常意味着您正在 JVM 中通过 LocateRegistry.createRegistry() 运行它,并且您已让它被垃圾收集。该方法的结果应存储在静态变量中。这也可能意味着您从一开始就没有启动注册表。
Your Registry has been unexported. This usually means that you are running it in a JVM via LocateRegistry.createRegistry() and you have let it become garbage-collected. The result of that method should be stored in a static variable. It may also mean that you never started the Registry in the first place.