United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6754672 java.io.IOException: The server sockets created using the LocalRMIServerSocketFactory
JDK-6754672 : java.io.IOException: The server sockets created using the LocalRMIServerSocketFactory

Details
Type:
Bug
Submit Date:
2008-10-01
Status:
Resolved
Updated Date:
2010-09-29
Project Name:
JDK
Resolved Date:
2008-11-14
Component:
core-svc
OS:
linux_ubuntu
Sub-Component:
java.lang.management
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
OpenJDK6
Fixed Versions:
6u12 (b01)

Related Reports
Backport:
Backport:

Sub Tasks

Description
Monitoring application with JConsole thows IOException in monitored application. This seems to be Ubuntu only issue.
Steps how to reproduce on clean install of Ubuntu 8.0.4:
1) Start Notepad with OpenJDK build 1.6.0_0-b11
java -jar /usr/lib/jvm/java-6-openjdk/demo/jfc/Notepad/Notepad.jar
2) start JConsole and attach to Notepad running on the same machine
3) The following exception is printed to console from Notepad:

01 Oct 2008 2:16:22 PM sun.rmi.transport.tcp.TCPTransport$AcceptLoop executeAcceptLoop
WARNING: RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=37278] throws
java.io.IOException: The server sockets created using the LocalRMIServerSocketFactory only accept connections from clients running on the host where the RMI remote objects have been exported.
	at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:89)
	at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:387)
	at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:359)
	at java.lang.Thread.run(Thread.java:636)

                                    

Comments
SUGGESTED FIX

There is a easy fix for this problem. Before checking IP address of all network interfaces, check that h=the remote address is loopback address. See the diff below:

--- LocalRMIServerSocketFactory.java.orig	2008-10-01 15:53:58.000000000 +0200
+++ LocalRMIServerSocketFactory.java	2008-09-30 16:50:22.000000000 +0200
@@ -55,6 +55,9 @@
                         "LocalRMIServerSocketFactory only accept connections " +
                         "from clients running on the host where the RMI " +
                         "remote objects have been exported.";
+                if (remoteAddr.isLoopbackAddress()) {
+                    return socket;
+                }
                 // Retrieve all the network interfaces on this host.
                 Enumeration<NetworkInterface> nis;
                 try {
                                     
2008-10-01
EVALUATION

This seems to be caused by this entry in /etc/hosts 

127.0.1.1	ubuntu.localdomain	ubuntu

This is done by default Ubuntu installation. 
127.0.1.1 is than used as remoteAddr in sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(). Subsequently 127.0.1.1 fails to be detected as IP address of any of the installed network interfaces and java.io.IOException is thrown. 
This problem can be also reproduce with JDK 6. It does not exist in JDK 7.
 
*** (#1 of 1): [ UNSAVED ] ###@###.###
                                     
2008-10-01
WORK AROUND

There are two possible workaround:

1) fix etc hosts or 2) disable local host checks.

Disabling local host checking can be done in two ways:

a) system-wide: uncomment the line

  # com.sun.management.jmxremote.local.only=false

  in jre/lib/management/management.properties

b) process based: pass -Dcom.sun.management.jmxremote.local.only=false
   on the java command line (attachee side)
                                     
2008-10-03



Hardware and Software, Engineered to Work Together