Announcement Announcement Module
No announcement yet.
RMI invocation attempts connecting to Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RMI invocation attempts connecting to


    I've exported a bean by using the RmiServiceExporter, and tries to access this bean through the RmiProxyFactoryBean. This works fine when client and server is on the same host, but fails with the following exception when client is set up on a different host. I have ofcourse set the RmiProxyFactoryBean.serviceUrl correctly, and the remote object is found, but as the exception shows it is the invocation of a method on the remote object that fails with a connect failure to Why is the loopback address being used? I found from the javadocs of RmiServiceExporter a suggestion to set , but this does not seem to help. [using spring 2.0]

    Exception in thread "main" org.springframework.remoting.RemoteConnectFailureE xception: Cannot connect to remote service [rmi://bernt:2000/Admin]; nested exception is java.rmi.ConnectException: Connection refused to host:; nested exception is: Connection refused
    Caused by: java.rmi.ConnectException: Connection refused to host:; nested exception is: Connection refused
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEnd
    at sun.rmi.transport.tcp.TCPChannel.createConnection(
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCP
    at sun.rmi.server.UnicastRef.invoke( 4)
    at org.springframework.remoting.rmi.RmiInvocationWrap per_Stub.invoke(Unknown Source)
    at org.springframework.remoting.rmi.RmiClientIntercep tor.doInvoke(
    at org.springframework.remoting.rmi.RmiClientIntercep tor.doInvoke(
    at org.springframework.remoting.rmi.RmiClientIntercep tor.invoke(
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :185)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(
    at $Proxy0.settle(Unknown Source)
    Caused by: Connection refused
    at Method)
    at .java:333)
    at ava:182)
    at ava:366)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.cre ateSocket(
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.cre ateSocket(
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEnd
    ... 24 more

  • #2

    Finally figured this out. RMI uses the following method to obtain a server hostname:

    In my case the IP returned was due to the setup on my linux box
    By changing the OS setup i got the correct external IP address returned.

    Strange though that neither$HOSTNAME nor -Djava.rmi.server.useLocalHostname=true did the job.


    • #3

      I too face same problem.

      Did you get it working???
      Please let me know.



      • #4
        I am having the exact same problem. Could you please post your exact changes to fix it? Thank You.


        • #5
          figured it out

          Well, since I didn't have time to wait for a reply, I went ahead and banged my head against it for a little while and figured out what to do.

          After re-reading the links from thosmas' posts, I realized that it was the hosts file on the server that needed to be fixed.

          If your hosts file has the first line as:
    localhost  {hostname}
          you must remove the {hostname} from that first line and add another line like:
          {actual ip address}   {hostname}
          That worked for me.


          • #6
            4 years later - but anyway... Unfortunately I can't muck with my /etc/hosts settings as if I remove the hostname from the entry for, other things will break (I know this because I had to add it in there to begin with to stop other things breaking!)

            The "$HOSTNAME" setting needs to be set in the invocation of the server binary that registers the service into the RMI registry.

            In the most basic example, the RMI registry being on

            user@server% rmiregistry &
            user@server% java example.Server
            Then on the client side (assuming it takes one argument specifying the server address):
            user@client% java example.Client


            • #7
              You can get 64MB Java for around $6 at - the cheapest Java hosting I managed to find. Java hosting is no more expensive. Check it out. I could not find better deal these days