How to organize RMI Client-Server architecture

You need two remote object classes. The first one is obtained via Naming.lookup(); it is a singleton; and it contains a login() method. This method returns the second remote object, which is not a singleton, not registered in the Registry, and is created anew for every return value. This object contains all the banking methods … Read more

Java RMI : connection refused

If you’re getting that on bind, rebind, or lookup, the Registry isn’t running. If you get it doing the remote call, see item A.1 in the RMI FAQ supplied with the Javadoc, and if you’re running Linux also check that your /etc/hosts file maps 127.0.0.1 to localhost and your real ip address to your real … Read more

Java RMI – Client Timeout

For socket read timeout, you can set your own factory like this, RMISocketFactory.setSocketFactory( new RMISocketFactory() { public Socket createSocket( String host, int port ) throws IOException { Socket socket = new Socket(); socket.setSoTimeout( timeoutMillis ); socket.setSoLinger( false, 0 ); socket.connect( new InetSocketAddress( host, port ), timeoutMillis ); return socket; } public ServerSocket createServerSocket( int port … Read more

NullPointerException in invokeLater while running through Java Webstart

I found what I believe to be a better solution to this bug. I just added the following code before calling SwingUtilities or any Swing related component method. It create a new AppContext for the RMI Thread (RMI thread must be the current Thread when running the code below). if(AppContext.getAppContext() == null){ SunToolkit.createNewAppContext(); } Due … Read more

RMI connection refused on localhost

The target of Naming.rebind() is the RMI Registry. It has to be running. It wasn’t running. So you couldn’t connect to it. So you got a ConnectException. I believe that the code for Implementation does not matter as it simply is the implemented interface that will run the code. This is both meaningless and irrelevant. … Read more

Why Java opens 3 ports when JMX is configured?

Contrary to common belief JMX/RMI doesn’t need to open all these ports. You can actually force them to be same which will mean that at the end of the day you’ll only need to punch one hole in the firewall (if firewall is your concern). Try setting System Properties: com.sun.management.jmxremote.port com.sun.management.jmxremote.rmi.port to the same value!! … Read more