Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Nov 2003 12:23:38 +0100
From:      David Israelsson <david@israelsson.org>
To:        freebsd-java@freebsd.org
Subject:   Re: RMI on FreeBSD
Message-ID:  <87n0aq6k3p.fsf@poh.gnapp.org>
References:  <87fzgjbdnq.fsf@poh.gnapp.org> <20031120095224.GR11487@starjuice.net> <877k1vb7tt.fsf@poh.gnapp.org> <20031120121152.GT11487@starjuice.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Sheldon Hearn <sheldonh@starjuice.net> writes:

> What do you expect to happen trying to connect to the local host before
> a listening service has bound to the appropriate port?  I'd expect
> "Connection refused".
>
Of course, that was only to make sure that it connects to the right
service.  No rmiregistry running -> connection refused, rmiregistry
running -> no exception thrown.  Hence, the rmi server successfully
connects to the rmiregistry.


> My original reply simply answered the question "is RMI broken on
> FreeBSD", for which the answer is probably "no".  I'm now guessing. :-)
>
Well, there's _something_ with FreeBSD that makes my RMI test case not
working.  Here's a test program that demonstrates the problem:

import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;

public class RMITest extends UnicastRemoteObject implements Remote
{
    public RMITest()
        throws RemoteException
    {
        super();
    }

    public static void main(String[] args)
        throws Exception
    {
        long millis = System.currentTimeMillis();
        Naming.rebind("//localhost:2001/Test", new RMITest());
        System.out.println("Got here after "
                           + ((System.currentTimeMillis() - millis) / 1000)
                           + " seconds.");
    }
}

And here's what I do with it:

poh:~/rmitest> javac RMITest.java 
poh:~/rmitest> rmic RMITest 
poh:~/rmitest> rmiregistry 2001&
[1] 42631
poh:~/rmitest> java RMITest
Got here after 76 seconds.
poh:~/rmitest>

It should take one or two, possibly three seconds, not 76.  And the
program shouldn't exit afterwards.  The same program works exactly
like it's supposed to when I boot Linux on the same computer.

Yes, it seems like a network problem.  What happens in the
Naming.rebind() method is that the rmi server reports its ip number
and the port it has allocated, then the rmiregistry tries to contact
the rmi server on that ip number and port.  This is where it fails.
It works if I first turn off the external interface.  In both cases
(FreeBSD and Linux) I get the same network settings from my isp's dhcp
server, and a traceroute to the remote ip number from my computer
indicates that the traffic does not go through any gateways.

Is my system broken?  If so, how could I fix it?  Can anybody get that
tiny little test program working?

    /David



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87n0aq6k3p.fsf>