RMI on FreeBSD

Andreas Kohn andreas.kohn at gmx.net
Fri Nov 21 03:38:34 PST 2003


On Fri, 21 Nov 2003 12:23:38 +0100
David Israelsson <david at israelsson.org> wrote:

> Sheldon Hearn <sheldonh at 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?

Hi, 

I tried it using jdk 1.4.2p5 on FreeBSD 5.1-CURRENT (Nov 17). Works flawlessly:

[mobile] ~/projects/java>javac RMITest.java
[mobile] ~/projects/java>/usr/local/java/bin/rmic RMITest
[mobile] ~/projects/java>java RMITest
Got here after 0 seconds.
<program continues to run>

--
Andreas Kohn


More information about the freebsd-java mailing list