编辑:用户已经解决了他自己的问题。 @KMuir即使您找到解决方案,也可以发布解决方案。
EmployeeService类的类接口是什么?你确定它实现了远程标记界面吗?
public interface TunnelingMessageBox extends Remote {
public void pushMessage(Message message) throws RemoteException;
//..more interface methods
}
public class TunnelingMessageBoxImpl implements TunnelingMessageBox {
public void pushMessage(Message message) throws RemoteException {
// does the magic
}
}
public class MyService {
private Registry registry;
private int port;
public void createRegistry(int port) throws RemoteException {
Registry reg;
try {
reg = LocateRegistry.createRegistry(port);
} catch (ExportException ex) {
// get existing registry instance.
reg = LocateRegistry.getRegistry(port);
}
this.port=port;
registry = reg;
}
public vooid closeRegistry() {
try {
Remote obj = (Remote)registry.lookup("box1");
UnicastRemoteObject.unexportObject(obj, true);
registry.unbind("box1");
} catch(Exception ex) { ex.printStacktrace(); }
registry=null;
}
public void registerServices() throws RemoteException {
TunnelingMessageBoxImpl mbox = new TunnelingMessageBoxImpl();
UnicastRemoteObject.exportObject(mbox, port);
registry.rebind("box1", mbox);
}
}
我想出了这个问题。 – KMuir
否。下面的*错误信息*是*打印*,这是*而不是*程序的执行。 – EJP