RMI Exception
NOTE: The address in the parameter should match the address you used to connect
java.rmi.ConnectException Connection refused to host: 127.0.0.1
The Java Remote Method Invocation (RMI) methods expect that the hostname of the server will resolve to the external IP address system. If the system is configured in a non-standard way, the name can resolve to the localhost (or 127.0.0.1) address. The RMI service is attached to an external IP address and not the internal or loopback address.
Fix: Configure IP and hostname resolution on the server. (The customer may not be able or authorized to do this.)
Workaround 1 – Add the following to the Java start line:
-Djava.rmi.server.hostname=$(hostname)
The string sequence $(hostname) can only be used in Unix system shell scripts. Try for the external host name if you use this string. On other systems you may need to use the permanent host address. Using a fixed value of any kind must be done thoughtfully as any change to the name or IP address of the server will also need to be made to the eFORMz startup.
Workaround 2 – Use the Web Server options. All the RMI connections would then be made to localhost (127.0.0.1) instead of the outside address.
Note: If the server is behind a firewall that uses Network-Address-Translation (NAT), either of the two workarounds will permit access to the services.
Other Variations
- Communication Exception
Error connecting to the Director. Failed to retrieve RMIServer stub: Javax.naming.CommunicationException (Root exception is Java.rmi.ConnectIOException: non-JRMP server at remote endpoint)
Java.rmi.ConnectIOException: non-JRMP server at remote endpoint means that a connection was made to something that did not communicate like the Director. Troubleshooting could include the following:
- Verify that the Director started. Use the
ps -ef
command to confirm a copy of Java is running Director. - Check the logs. Did the Director start or is there an exception?
- Check the open ports. Use the
netstat
command with options to show the open ports and what application opened them.
- Service Unavailable Exception
Error connecting to the Director. Failed to retrieve RMIServer stub: Javax.naming.ServiceUnavailableException (Root exception is Java.rmi.ConnectException: Connection refused to host: localhost: nested exception)
This problem was seen on a Windows system that was recently updated. The following steps resolved the error:
- Remove system from the domain and rejoin.
- Verify that the eFORMz service runs as Network Service.
Remote interface
Java RMI (Remote Interface) needs a connection using an open port. For example, by default most ports are closed from in/out of Amazon Web Services. This could lead to a java.rmi.ConnectException Connection refused to host
error. You can configure AWS to use a specific port. Doing so requires adding the below value to your DirectorSettings.xml.
<Setting Value="8996" Name="JmxPort" />
Port 8996 is used every time the Director starts up and then the Client/Toolkit can connect using this port without being refused.
Keywords: Failed to Retrieve RMI Server Stub, RMI