java - How to set a custom port for RMI regisrty? -


in rmi program want set rmi registry on port 8080, when it, exception.

here server code

public class server {     public static void main(string[] args) {         try {             locateregistry.createregistry(8080);             mathserverimpl mathserver = new mathserverimpl();             naming.rebind("mathserver", mathserver);             system.out.println("math server has started , running");         } catch (remoteexception | malformedurlexception e) {             system.out.println(e.getmessage());             e.printstacktrace();         }     } } 

the code works port 1099, it's default port far know, case gives me java.net.connectexception, , here log.

java.rmi.connectexception: connection refused host: 10.100.25.173; nested exception is:      java.net.connectexception: connection refused     @ sun.rmi.transport.tcp.tcpendpoint.newsocket(tcpendpoint.java:619)     @ sun.rmi.transport.tcp.tcpchannel.createconnection(tcpchannel.java:216)     @ sun.rmi.transport.tcp.tcpchannel.newconnection(tcpchannel.java:202)     @ sun.rmi.server.unicastref.newcall(unicastref.java:341)     @ sun.rmi.registry.registryimpl_stub.rebind(unknown source)     @ java.rmi.naming.rebind(naming.java:177)     @ server.server.main(server.java:16)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ com.intellij.rt.execution.application.appmain.main(appmain.java:134) caused by: java.net.connectexception: connection refused     @ java.net.plainsocketimpl.socketconnect(native method)     @ java.net.abstractplainsocketimpl.doconnect(abstractplainsocketimpl.java:339)     @ java.net.abstractplainsocketimpl.connecttoaddress(abstractplainsocketimpl.java:200)     @ java.net.abstractplainsocketimpl.connect(abstractplainsocketimpl.java:182)     @ java.net.sockssocketimpl.connect(sockssocketimpl.java:392)     @ java.net.socket.connect(socket.java:579)     @ java.net.socket.connect(socket.java:528)     @ java.net.socket.<init>(socket.java:425)     @ java.net.socket.<init>(socket.java:208)     @ sun.rmi.transport.proxy.rmidirectsocketfactory.createsocket(rmidirectsocketfactory.java:40)     @ sun.rmi.transport.proxy.rmimastersocketfactory.createsocket(rmimastersocketfactory.java:147)     @ sun.rmi.transport.tcp.tcpendpoint.newsocket(tcpendpoint.java:613)     ... 11 more 

you creating registry on port 8080 attempting rebind object in default registry on port 1099. need either:

  • pass full url naming.rebind including port number, i.e. //localhost:8080/mathserver or
  • save reference registry object returned locateregistry.createregistry , bind object using registry's instance methods rather static methods of naming

similarly, need use full //localhost:8080/mathserver url form in clients when lookup object, make sure they're talking right registry.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -