java - RMI重新绑定(bind)JRMP错误

标签 java rmi policy codebase

几天以来,当我尝试运行我的 java 服务器应用程序时,出现以下错误:

SEVERE: Stratego server exception: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
java.net.SocketTimeoutException: Read timed out

我的主要方法如下:

Stratego stratego = new Stratego();
try
{
    if (System.getProperty("java.security.policy") == null)
    {
        System.setProperty("java.security.policy", "src/Server/Policy/server.policy");
    }
    if (System.getProperty("java.rmi.server.codebase") == null)
    {
        System.setProperty("java.rmi.server.codebase", "file:/D:/.../build/classes");
    }
    if (System.getSecurityManager() == null)
    { 
        System.setSecurityManager(new RMISecurityManager());
    }
    LocateRegistry.createRegistry(9292);
    Naming.rebind("rmi://localhost:9292/StrategoServer", stratego);

    Logger.getLogger(Stratego.class.getName()).info("Stratego server ready");
}
catch (Exception e)
{
    Logger.getLogger(Stratego.class.getName()).log(Level.SEVERE, "Stratego server exception: {0}", e.toString());
    }

策略、代码库和 SecurityManager 都是新的,但当我将它们注释掉时,我仍然收到此错误。之前一切都运作良好。 谁能告诉我为什么?

哦,顺便说一句,我使用 Windows 7 x64 和 JDK 7

最佳答案

原来是端口被占用了(不知道怎么回事)。当我将端口从 9292 更改为 9288 时,它起作用了。

关于java - RMI重新绑定(bind)JRMP错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10595679/

相关文章:

Java类路径问题

java.rmi.ServerException : RemoteException occurred in server thread (ClassNotFoundException) 异常

spring - 集成测试分布式 Java EE 应用程序

tensorflow - tf-agent 的 `policy` 和 `collect_policy` 有什么区别?

FlashLite 2.x/3.0 跨域策略文件

java - 在对 Java 代码进行逆向工程时,EA 能否像 Visual Paradigm 一样显示包之间的依赖关系?

java - "This GPIO pin already exists:"GPIO 1 第二次出现异常

java - 将长文本分成页面以供 viewpager 使用

Java拒绝访问属性权限

android - 当设备上有相同的 native (Apple/Google) 帐户但应用程序帐户不同时恢复应用内购买