Why is Java RMI server showing an error message when I try to run it? -
the following exception thrown after execution of program.
unresolved compilation problem: method bind(string, remote) in type registry not applicable arguments (string, employeermimain)
public static void main(string args[]){ try { employeeservice obj = new employeeservice(); registry r = locateregistry.createregistry(1234); r.bind("remote", obj); } catch (remoteexception e) { e.printstacktrace(); } catch (alreadyboundexception e) { e.printstacktrace(); } }
edit: user solved own problem. @kmuir practice post solution if found it.
what class interfaces of employeeservice class? sure implements remote marker interface?
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 { // 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) { // 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); } }
Comments
Post a Comment