0
我有folloving 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;
}
的实施,如下头,身体只包含未真正落实,他们只是thow UnsupportedOperationException
方法:
public class ChatSystemImpl implements ChatSystem
的ChatSystem
接口在其他项目中,然后是源代码的其余部分,如果它是任何重要的。
谢谢。