【问题标题】:Server RMI stop automatically when I start it服务器 RMI 在我启动时自动停止
【发布时间】:2014-05-17 06:42:32
【问题描述】:

我很法语,很抱歉我的英语。

我正在尝试启动服务器 rmi,但应用程序停止但出现错误:

这是我的代码:

公共类服务器{

public static void main(String[] args) {

    try {



        RemoteFunction  skeleton = (RemoteFunction) UnicastRemoteObject.exportObject(new FunctionImpl(), 0); 

        int port = Integer.parseInt(Jndiprop.getString("port"));

        Registry registry = LocateRegistry.createRegistry(port);


        registry.rebind(Jndiprop.getString("url"), skeleton); 

        System.out.println("Rmi start");

    } catch (Exception e) {
        e.printStackTrace();
    }




}

}

端口和url都可以。

有人可以帮助我吗?

【问题讨论】:

    标签: java rmi


    【解决方案1】:

    您必须将注册表存储在静态变量中。否则它可能会被垃圾回收,这会导致一系列事件允许整个 JVM 退出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-07
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多