Monday, 15 July 2013

java - Rmi connection refused with localhost -


I have a problem using Java RMI:

When I try to run my server I am receiving, I get a connected approach (see below).

Exception occurs when the reboot method is executed:

  runtime .getRuntime (). Exec ("rmiregistry 2020"); MyServer Server = New Mysore (); Naming.rebind ("// localhost: 2020 / remote dotdoint handler", server);  

When using rmi: // localhost: 2020 / Instead of the remote dotdoint handler, it does not work either. The use of the default port also does not work. I also tried to use the IP-address 127.0.0.1, but with the same effect.

I runtime Arges:

  -Djava.security.policy = java.security Sbipradrshn  
 exception in thread "main" java .rmi.ConnectException: Connection refused to host: localhost; Nested exception is: java.net.ConnectException: Connection refused on sun.rmi.transport.tcp.TCPEndpoint.newSocket (TCPEndpoint.java:574) sun.rmi.transport.tcp.TCPChannel.createConnection (TCPChannel.java: 185) sun.rmi.transport.tcp.TCPChannel.newConnection (TCPChannel.java:171) on sun.rmi.server.UnicastRef.newCall (UnicastRef.java:306) on sun.rmi.registry.RegistryImpl_Stub.rebind (unknown source ) On . java.rmi.Naming.rebind (Naming.java:160) on be.fortega.knx.server.Main (Main.java:25) on be.fortega.knx.server.Main.main (on Main.java: java Connection connection due to .net.ConnectException :: 16) java.net.PlainSocketImpl.doConnect (PlainSocketImpl.java:333) java.net.PlainSocketImpl.connectToAddress at java.net.PlainSocketImpl.socketConnect (native resident method) (from PlainSocketImpl refused Java: 195) Java.net on java.net.PlainSocketImpl.connect (PlainSocketImpl.java:182) java.net.SocksSocketImpl.connect (SocksSocketImpl.java:433) on java.net.Socket.connect (so On java.net.Socket.connect (Socket.java:474) on socket, java.net.Socket. (Socket.java:371) on java.net.Socket) (socket.java 184) at sun.rmi.transport .proxy.RMIDirectSocketFactory.createSocket sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket (RMIMasterSocketFactory.ja va: 128) to (RMIDirectSocketFactory.java:22) on sun.rmi.transport.tcp.TCPEndpoint.newSocket (TCPEndpoint.java ---- 69) ... 7 more 

There was a similar problem with that connection exception, it is thrown when the registry has not yet started (like in your case) or when the registry Already unexpected (like in my case).

But start a small comment registry for the difference between 2 methods:

  runtime .getRuntime (). Exec ("rmiregistry 2020");  

In a new process, javas run rmiregistry.exe in bin-directory and your parallel Java code continues.

  LocateRegistry.createRegistry (2020);  

Registry starts, returns the reference to that registry remote object and then continues with the next statement.

In your case the registry has not started in time when you try to force your object


No comments:

Post a Comment