RMI 找不到绑定对象?

发布于 2024-10-16 18:09:38 字数 1586 浏览 4 评论 0原文

我有以下 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绾颜 2024-10-23 18:09:38

您的注册表尚未导出。这通常意味着您正在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文