我创建了一个简单的 java RMI 程序来了解它是如何工作的。但是当我尝试运行我的服务器端时,它会引发以下异常。
编辑:我们正在使用代理连接...
Remote exception: java.rmi.ConnectException: Connection refused to host: 10.7.150.18; nested exception is:
java.net.ConnectException: Connection refused: connect
这是我的服务器端代码供您参考...
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class SampleServerImpl extends UnicastRemoteObject implements SampleServer
{
SampleServerImpl() throws RemoteException
{
super();
}
@Override
public int sum(int a,int b) throws RemoteException
{
return a + b;
}
public static void main(String[] args)
{
try
{
//set the security manager
//System.setSecurityManager(new RMISecurityManager());
//create a local instance of the object
SampleServerImpl Server = new SampleServerImpl();
//put the local instance in the registry
Naming.rebind("//10.7.150.18:9999" , Server);
System.out.println("Server waiting.....");
}
catch (java.net.MalformedURLException me)
{
System.out.println("Malformed URL: " + me.toString());
}
catch (RemoteException re)
{
System.out.println("Remote exception: " + re.toString());
}
}
}
请指导我摆脱这个问题......