Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] RMI Server on loopback

You can utilize the JMXServiceURL on the constructor of the jmx ConnectorServer to establish a reference to a specific host. (which it seems is the way you have setup)

As for RMI, its registry can only be created in code with a port parameter.
http://docs.oracle.com/javase/8/docs/api/java/rmi/registry/LocateRegistry.html

Notice there's no createRegistry() with a host option?

There are a number of RMI specific system properties.
https://docs.oracle.com/javase/8/docs/technotes/guides/rmi/javarmiproperties.html

The one called  -Djava.rmi.server.hostname=127.0.0.4 seems like it might be the one, but then again it makes no mention of how it binds the RMI ServerSocket.

Also of note, the javadoc seem to indicate that the only way to accomplish this is with a custom RMISocketFactory implementation.
https://docs.oracle.com/javase/8/docs/api/java/rmi/server/RMISocketFactory.html

Joakim Erdfelt / joakim@xxxxxxxxxxx

On Tue, Jan 26, 2016 at 5:50 PM, Steven Katz <steven.katz@xxxxxxxxxxx> wrote:
Hi,

Thanks for the reply.  

I am, in fact, trying to start jmx/rmi on the loopback address 127.0.0.4, but jetty insists on starting the rmi regisrty on 0.0.0.0 when it detects you are using a loopback address (that the code I posted).

I have configured jetty-jmx-remote.xml

I am starting with these properties on the commandline:
 jetty.jmxremote.rmiport=1199 jetty.jmxremote.rmihost=127.0.0.4

After it starts, "netstat -an | grep 1199" shows

 TCP    0.0.0.0:1199           0.0.0.0:0              LISTENING

Which indicates that it is listen on all address not just 127.0.0.4

Is there any way I can limit it to just 127.0.0.4?

Steven Katz | Senior Director, Architecture
AolPlatforms.
office: 617.874.5448
email: steven.katz@xxxxxxxxxxx

On Tue, Jan 26, 2016 at 7:38 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
I think you meant the jmx ConnectorServer, not the ConnectorService

That address (127.0.0.4) is loopback, and will start the JMX registry.

Test it yourself.

        InetAddress addr = InetAddress.getByName("127.0.0.4");
        System.out.printf("Addr %s isLoopbackAddress = %b%n", addr, addr.isLoopbackAddress());

If you get false, then you have a more fundamental configuration issue to noodle through, as the default implementation of java.net.Inet4Address.isLoopbackAddress() just checks that the first octet for the IP is 127.


Joakim Erdfelt / joakim@xxxxxxxxxxx

On Tue, Jan 26, 2016 at 4:54 PM, Steven Katz <steven.katz@xxxxxxxxxxx> wrote:
I'm trying to start jetty so that jmx and the rmi registry are started on a loopback address (specifically, 127.0.0.4).  The code seem to specifically disallow this.  

From ConnectorService:

        if(hostAddress.isLoopbackAddress())
        {
            if (rmiPort == 0)
            {
                ServerSocket socket = new ServerSocket(0);
                rmiPort = socket.getLocalPort();
                socket.close();
            }
            else
            {
                try
                {
                    // Check if a local registry is already running
                    LocateRegistry.getRegistry(rmiPort).list();
                    return null;
                }
                catch (Exception ex)
                {
                    LOG.ignore(ex);
                }
            }

            _registry = LocateRegistry.createRegistry(rmiPort);
            Thread.sleep(1000);

            rmiHost = InetAddress.getLocalHost().getCanonicalHostName();
            return rmiHost + ':' + Integer.toString(rmiPort);
        }


Does anyone know why this is the case or a way I can work around it?

Steven Katz | Senior Director, Architecture
AolPlatforms.
office: 617.874.5448
email: steven.katz@xxxxxxxxxxx

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top