I have been attempting to get an RMI Client and Server to run using
2 Linux boxes running Red Had 6.1 (one dual boots 95). The Client
and Server are "textbook" examples.
I have run them succesuffly on Win95, WinNT and Solaris
networks. When I run both on the same linux machine, it works. In
addition, when I run the Server on the Win95 box and the Client on
the Linux box the program works but when the Server is on the Linux box I
get the same error message that I get when the client is on one linux box
and the server is on another:
java.rmi.ConnectException: Connection refused to host: 127.0.0.1;
nested exception is: java.net.ConnectException: Connection
refused.net.ConnectException: Connection refused at
java.net.PlainSocketImpl.socketConnect(Native Method) at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:301) at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:121)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:108) at
java.net.Socket.<init>(Socket.java:265) at
java.net.Socket.<init>(Socket.java:94) at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDir
ectSocketFact ory.java:25) at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIM
asterSocketFact ory.java:120) at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:493)
at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:1
90) at
sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:17
4) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:83) at
Many of you will probably recognize this as a frequent problem that has
been discussed before and will probably offer several solutions:
1) Fix the .java.policy file.
I have allready tried this and it did not fix the problem. Currently the
.java.policy file on both machines reads like this:
grant {
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535",
"connect,accept,resolve";
permission java.net.SocketPermission "*:80", "connect";
};
2) Remove the skeleton files from the client.
I allready tried this and it did not fix the problem.
3) Specify the port number in the clients Naming.lookup call.
I allready tried this and it did not fix the problem.
I have added some debug code to the PlainSocketImpl class to see
what the socketConnect method is trying to connect to and found some
interesting results:
On the server side, when the server is started up first a connection will
be made to 192.168.0.2 (the server) port 1099 then a connection will
be made to 127.0.0.1 port 1184 (this will vary each time the server is
started)
On the client side, first a connection will be made to 192.168.0.2 port
1099 then a connection will be attempted to 127.0.0.1 port 1184. At
this point the exception is raised.
What I think is happening is that every time a Remote object is started, it
connects to the port 1099 and is assigned a port. When a client attempts
to do the naming.lookup it contacts the server machine and requests the
location of the remote object from port 1099 on the server machine.
The server machine then returns the machine name and port number
where the remote object is running and the client then connects to there.
Unfortunatly the server appears to be returning 127.0.0.1 as the location
of the remote object when it should be returning the actual address
(192.168.0.2).
My questions are
1) Has anyone EVER gotten RMI to work properly between multiple
linux machines? If my analysis is correct, it should never work.
2)Is there something I could do on the Server side to get it to return the
correct address 192.168.0.2 to the client?
3) Where do I find the source code for
sun.rmi.transport.proxy.RMIDirectSocketFactory?
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]