大家好!我有问题,我的RMI例子。一周前,我尝试着开始我的第一个RMI示例,它成功了,但我删除了项目,并尝试再次创建,但我不能,因为‘抛出ExportException’。我做错什么了?也许我需要重新启动rmiregistry.exe或者别的什么?
public interface IExample extends Remote {
public String getMessage(String input) throws RemoteException;
}
public class ExampleImpl extends UnicastRemoteObject implements IExample {
public ExampleImpl() throws RemoteException {
super();
}
@Override
public String getMessage(String input) throws RemoteException {
return "Hi " + input + "!!!";
}
public static void main(String... args) throws RemoteException, MalformedURLException {
System.setSecurityManager(new RMISecurityManager());
String name = "myexample";
IExample engine = new ExampleImpl();
IExample stub =
(IExample) UnicastRemoteObject.exportObject(engine, 1090);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(name, stub);
}
}附注:谢谢大家,为我的英语道歉。P.p.s.还有我愚蠢的问题。
发布于 2013-10-25 21:34:05
扩展UnicastRemoteObject的类在构造时自动导出。你不必自己动手。删除exportObject()调用。
https://stackoverflow.com/questions/19599331
复制相似问题