RMI重新绑定JRMP错误

时间:2012-05-15 07:00:09

标签: 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

1 个答案:

答案 0 :(得分:1)

原来,该港口被占用(不知道如何)。当我将端口从9292更改为9288时,它工作正常。