几天以来,当我尝试运行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时,它起作用了。