Re: RMI & connection refused



On Sun, 02 Aug 2009 13:39:01 +0100, Tom Anderson wrote:

On Sat, 1 Aug 2009, Duane Evenson wrote:

Here's my commands:

rmiregistry &
java -Djava.security.policy=policy RMIServer localhost 1099 &
java -Djava.security.policy=policy RMIClient localhost 1099

The problem is with the next command from a remote host:

java -Djava.security.policy=policy RMIClient adam 1099
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused

Why is it connecting to 127.0.0.1? That's the local loopback interface -
you know about that, right? If the client and server are on different
machines, that doesn't seem like a totally likely to work thing to do.
What's your /etc/hosts look like? What to you get if you do 'ping adam'?

A simple but good diagnostic tool in situations like this is telnet. On
the client machine, telnet to port 1099 on the server machine. If you
manage to make a connection, you know that there's nothing wrong at the
network level, and any problem must be in the program. If you can't make a
connection, you know there's trouble with the network - firewalls, DNS,
routing, something like that.

tom

I assume that reference to 127.0.0.1 isn't important in tracing out the
problem. It is just how the registry refers to the server -- after all
they are the only two who are on the same server, if the client knows the
IP of the registry, it knows the IP of the server.

I think I know the problem here. I assumed the server would keep the port
open with which it communicate with the registry. Then, at the network
level, would use "Related" state to switch to communicating with the
client. Further reading of the Javadoc for UnicastRemoteObject finds
that the server listens on a second, random port for a client. I don't
know how most firewalls are supposed to handle this, but I used a
different constructor that specified a fixed, non-firewalled port.

Now I'm getting another problem -- when I execute the server, I'm getting
errors, but the server still continues (hangs like it should) but nothing
is registered with the RMI name server.

I'm getting:
Server exception: java.rmi.ServerException: RemoteException occurred in
server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested
exception is: java.lang.ClassNotFoundException: dbServer.Server
java.rmi.ServerException: RemoteException occurred in server thread;
nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested
exception is: java.lang.ClassNotFoundException: dbServer.Server at
sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:385)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153) at
java.security.AccessController.doPrivileged(Native Method) at
sun.rmi.transport.Transport.serviceCall(Transport.java:149)
....

Using the -verbose flag, I can see that dbServer.Server (which is the
interface for the server is loading OK:

....
[Loaded java.security.cert.Certificate from /usr/local/jdk1.5.0_06/jre/lib/rt.ja
r]
[Loaded java.rmi.Remote from /usr/local/jdk1.5.0_06/jre/lib/rt.jar]
[Loaded dbServer.Server from file:/home/duanee/]
[Loaded java.rmi.server.RemoteObject from /usr/local/jdk1.5.0_06/jre/lib/rt.jar]
[Loaded java.rmi.server.RemoteServer from /usr/local/jdk1.5.0_06/jre/lib/rt.jar]
[Loaded java.rmi.server.UnicastRemoteObject from /usr/local/jdk1.5.0_06/jre/lib/
rt.jar]
[Loaded dbServer.ServerImpl from file:/home/duanee/]
[Loaded java.io.IOException from /usr/local/jdk1.5.0_06/jre/lib/rt.jar]
[Loaded java.rmi.RemoteException from /usr/local/jdk1.5.0_06/jre/lib/rt.jar]
[Loaded java.sql.SQLException from /usr/local/jdk1.5.0_06/jre/lib/rt.jar]
[...

I'm running Java 1.5 so I don't need stubs. Still, I tried precompiling
them with rmic, but the problem persists.



.



Relevant Pages

  • return from server only works for built-in types
    ... But when I call _r.GetStatisticsthe client fails with the exception shown ... GetStatistics fails when client and server is on different networks. ... Win32 Version: 2.0.50727.832 ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: What multi-tier components to use
    ... Enterprise Java Beans. ... > with every change in the parameter list, you could make your new server ... But surely if you have an old client and the interfaces are still valid on ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Java GSS client talking to SSPI C++ Server
    ... The Java client uses JAAS to authenticate and impersonate using ... with the server. ... My concern is the compatibility of the tokens generated by JAVA GSS-API ...
    (comp.protocols.kerberos)
  • Re: Best Programming language for Network programming (serious server application
    ... back to the client. ... So the server needs to be a heavily multi- ... required to display the same on a real-time basis. ... I m wondering of using java for my client application development ...
    (comp.programming)
  • Re: How to detect if client or server are not responding
    ... you are asking if raising an exception could cause a COM call not ... responds to the server crashing. ... client implemented in an ActiveX plugin DLL running in a browser. ... If a COM service crashes in the middle of a call, it may take up to 6 ...
    (microsoft.public.win32.programmer.ole)